-
Notifications
You must be signed in to change notification settings - Fork 754
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
Refactor outbound authentication with custom providers and handlers #15696
Merged
ldclakmal
merged 73 commits into
ballerina-platform:jballerina
from
ldclakmal:refactor-outbound-auth
Jun 25, 2019
Merged
Refactor outbound authentication with custom providers and handlers #15696
ldclakmal
merged 73 commits into
ballerina-platform:jballerina
from
ldclakmal:refactor-outbound-auth
Jun 25, 2019
Conversation
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
…ina-lang into refactor-outbound-auth # Conflicts: # stdlib/http/src/main/ballerina/http/client_endpoint.bal # stdlib/http/src/main/ballerina/http/http_secure_client.bal # tests/ballerina-integration-test/src/test/resources/auth/authservices/11_token_propagation_basic_auth_test.bal # tests/ballerina-integration-test/src/test/resources/auth/authservices/12_token_propagation_jwt_test.bal # tests/ballerina-integration-test/src/test/resources/auth/authservices/13_token_propagation_jwt_reissuing_test.bal # tests/ballerina-integration-test/src/test/resources/auth/authservices/14_token_propagation_jwt_reissuing_negative_test.bal
…ina-lang into refactor-outbound-auth
…ina-lang into refactor-outbound-auth
praneesha
reviewed
Jun 20, 2019
examples/secured-client-with-basic-auth/secured_client_with_basic_auth.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-basic-auth/secured_client_with_basic_auth.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-basic-auth/secured_client_with_basic_auth.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-basic-auth/secured_client_with_basic_auth.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-basic-auth/secured_client_with_basic_auth.description
Outdated
Show resolved
Hide resolved
examples/secured-client-with-jwt-auth/secured_client_with_jwt_auth.description
Outdated
Show resolved
Hide resolved
examples/secured-client-with-jwt-auth/tests/secured_client_with_jwt_auth_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-jwt-auth/tests/secured_client_with_jwt_auth_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
praneesha
reviewed
Jun 20, 2019
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-client-with-oauth2/secured_client_with_oauth2.bal
Outdated
Show resolved
Hide resolved
examples/secured-service-with-jwt/tests/secured_service_with_jwt_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-service-with-jwt/tests/secured_service_with_jwt_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-service-with-jwt/tests/secured_service_with_jwt_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-service-with-jwt/tests/secured_service_with_jwt_test.bal
Outdated
Show resolved
Hide resolved
examples/secured-service-with-jwt/tests/secured_service_with_jwt_test.bal
Outdated
Show resolved
Hide resolved
praneesha
reviewed
Jun 20, 2019
stdlib/auth/src/main/ballerina/auth/inbound_basic_auth_provider.bal
Outdated
Show resolved
Hide resolved
stdlib/auth/src/main/ballerina/auth/inbound_basic_auth_provider.bal
Outdated
Show resolved
Hide resolved
stdlib/auth/src/main/ballerina/auth/inbound_basic_auth_provider.bal
Outdated
Show resolved
Hide resolved
stdlib/auth/src/main/ballerina/auth/inbound_basic_auth_provider.bal
Outdated
Show resolved
Hide resolved
stdlib/auth/src/main/ballerina/auth/inbound_basic_auth_provider.bal
Outdated
Show resolved
Hide resolved
praneesha
reviewed
Jun 21, 2019
praneesha
reviewed
Jun 21, 2019
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
praneesha
reviewed
Jun 21, 2019
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
stdlib/http/src/main/ballerina/http/auth/bearer_auth_handler.bal
Outdated
Show resolved
Hide resolved
praneesha
reviewed
Jun 21, 2019
Co-Authored-By: praneesha <[email protected]>
Co-Authored-By: praneesha <[email protected]>
Co-Authored-By: praneesha <[email protected]>
…llerina-lang into refactor-outbound-auth # Conflicts: # stdlib/ldap/src/main/java/org/ballerinalang/stdlib/ldap/nativeimpl/InitLdapConnectionContext.java
…llerina-lang into refactor-outbound-auth
…llerina-lang into refactor-outbound-auth
ayomawdb
approved these changes
Jun 25, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
This PR provides the capability of custom authentication providers and handlers engagement for outbound authentication. The current design of HTTP outbound authentication is not extensible. Also, it creates cyclic dependencies, in future (ex: When adding JWKs support). And the user cannot attach a custom provider and handler because the authentication mechanisms and their related logic are tightly coupled with the http_secure_client of Ballerina.
This is a similar approach done at refactoring inbound authentication with custom providers and handlers by #15056.
Refer the email discussion @ ballerina-dev [1] for more information.
[1] https://groups.google.com/d/msg/ballerina-dev/OvlUscsjT-I/VmTTBg-DBAAJ
Fixes #15487
Approach
ballerina/auth
module provides an abstract object namedOutboundAuthProvider
, which is responsible for the following 2 actions:generateToken()
- Generate the token that is used to authenticate with the external endpointinspect(map<anydata> data)
- Inspect the received map of data from outbound authenticationauth:OutboundBasicAuthProvider
,jwt:OutboundJwtAuthProvider
andoauth2:OutboundOAuth2Provider
are implementations of theauth:OutboundAuthProvider
for different authentication mechanisms.ballerina/http
module provides an abstract object namedOutboundAuthnHandler
, which is responsible for the following 2 actions:prepare(http:Request req)
- Prepare the HTTP request for outbound authenticationinspect(http:Request req, http:Response resp)
- Inspect the received HTTP request and response from outbound authenticationhttp:BasicAuthHandler
andhttp:BearerAuthHandler
are implementations of thehttp:OutboundAuthHandler
for different use cases.If a user wants to engage a custom authentication logic, it is needed to write an outbound custom auth provider and outbound custom auth handler as follows. Or else already implemented handlers and providers can be used.
Outbound Custom Auth Provider
Outbound Custom Auth Handler
Samples
Sample 1 - Outbound authentication with Basic Auth
Sample 2 - Outbound authentication with JWT Auth
Sample 3 - Outbound authentication with OAuth2
Sample 4 - Outbound authentication with Custom Auth
This is a sample program which handles authentication with authorization with a custom header.
sample.bal
outbound_custom_auth_provider.bal
outbound_custom_auth_handler.bal
Check List