-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[broker][authentication]Support pass http auth status #14044
Merged
tuteng
merged 28 commits into
apache:master
from
AmateurEvents:fixed/support-pass-http-auth-status
Feb 28, 2022
Merged
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
77b049f
Support pass http auth status
tuteng ce3c5d3
Fixed comment and style
tuteng 1badfaa
Add method name for oauth2 auth
tuteng cbc79e2
Change var type to private from public
tuteng 8924aa6
Fixed style check
tuteng 3cc0a9d
Fixed function interface and client api var
tuteng 3407283
Update auth method name
tuteng a4d8718
Backward compatible
tuteng 78c7726
Merge branch 'master' into fixed/support-pass-http-auth-status
tuteng 713b1d1
Fixed style
tuteng 6c34f62
Delete whitespace
tuteng 8c2ef67
Reduce length
tuteng c9f8000
Update test
tuteng 3fb6e3b
Update remote addr
tuteng 97ae44d
Fixed authentication token test
tuteng 197411f
Fixed authentication token test
tuteng b20a7d5
Update var type, add final field, add comment for authentication method
tuteng 0467c96
Update comment
tuteng 3fc7d57
Fixed test
tuteng 5b08617
Fixed auth test
tuteng ae5b447
Update comment
tuteng e4efa86
Revert code
tuteng bb1ebfe
Remove no used var
tuteng 3764121
Update map headers to unmodifiableMap type
tuteng 673818c
Merge branch 'master' into fixed/support-pass-http-auth-status
tuteng 49c1080
Remove redundant final
tuteng b1def58
Fixed style
tuteng 485e961
Fixed comment
tuteng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
|
||
import org.apache.pulsar.broker.authentication.AuthenticationDataHttps; | ||
import org.apache.pulsar.broker.authentication.AuthenticationService; | ||
import org.apache.pulsar.broker.authentication.AuthenticationState; | ||
import org.apache.pulsar.common.sasl.SaslConstants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
@@ -76,8 +77,15 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha | |
// not sasl type, return role directly. | ||
String role = authenticationService.authenticateHttpRequest((HttpServletRequest) request); | ||
tuteng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
request.setAttribute(AuthenticatedRoleAttributeName, role); | ||
request.setAttribute(AuthenticatedDataAttributeName, | ||
new AuthenticationDataHttps((HttpServletRequest) request)); | ||
String authMethodName = httpRequest.getHeader("X-Pulsar-Auth-Method-Name"); | ||
tuteng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (authMethodName != null && authenticationService.getAuthenticationProvider(authMethodName) != null) { | ||
AuthenticationState authenticationState = authenticationService | ||
.getAuthenticationProvider(authMethodName).newHttpAuthState(httpRequest); | ||
request.setAttribute(AuthenticatedDataAttributeName, authenticationState.getAuthDataSource()); | ||
michaeljmarshall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
request.setAttribute(AuthenticatedDataAttributeName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backward compatible |
||
new AuthenticationDataHttps((HttpServletRequest) request)); | ||
} | ||
if (LOG.isDebugEnabled()) { | ||
LOG.debug("[{}] Authenticated HTTP request with role {}", request.getRemoteAddr(), role); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because providers are a list