Introducing Common JWT support for Pod APIs#618
Merged
symphony-mariacristina merged 36 commits intofinos:mainfrom Jan 14, 2022
Merged
Introducing Common JWT support for Pod APIs#618symphony-mariacristina merged 36 commits intofinos:mainfrom
symphony-mariacristina merged 36 commits intofinos:mainfrom
Conversation
Goal of this implementation is to be able to start using the common JWT to call pod public APIs. First of all the usage of common jwt can be configured by a configuration property in the application.yaml file. when the feature is enabled, the Authorization token will be used as header for each Pod call instead of the sessionToken. This is possible thanks to a new ApiClient called BearerEnabledApiClient. When the bot is in common jwt mode enabled we will check the expiration date found in the jwt before making any call. If this date is expired then we eill trigger the refresh token and a new common jwt will be requested and saved in the AuthSession.
…hSession.java Co-authored-by: Youri Bonnaffé <63661676+symphony-youri@users.noreply.github.com>
…o commonJwtPod
…anges after finos#619 implementation
thibauult
reviewed
Jan 11, 2022
Missing: - Check if we can remove AuthSession.refreshAuthToken - Make refresh bearer token happen before 401 - Finish clean up
b0dd149 to
50ff111
Compare
thibauult
reviewed
Jan 12, 2022
…nly + adding test to SymphonyBdkAutoConfigurationTest
thibauult
reviewed
Jan 12, 2022
Member
thibauult
left a comment
There was a problem hiding this comment.
I think that will be my last comments :)
Comment on lines
+280
to
+286
| private String[] withEnforcedSecurityScheme(String[] authNames) { | ||
| if (authNames == null) { | ||
| authNames = new String[0]; | ||
| } | ||
|
|
||
| return Stream.concat(this.enforcedAuthenticationSchemes.stream(), Arrays.stream(authNames)).toArray(String[]::new); | ||
| } |
Member
There was a problem hiding this comment.
At some point it think that we will have to create an AbstractApiClient in the symphony-bdk-http-api module to avoid this kind of duplications
…hSession.java Co-authored-by: Youri Bonnaffé <63661676+symphony-youri@users.noreply.github.com>
…thSession.java Co-authored-by: Youri Bonnaffé <63661676+symphony-youri@users.noreply.github.com>
…ing the call (BDK core).
Since common jwt is not yet available for Obo calls if the bot configuration contains an app with the common jwt feature enabled, we are going to fail the bot start up.
006c95d to
f8d939a
Compare
To avoid calling the login api to many times, we now first try to refresh the expired jwt by calling the idm/tokens endpoint. if that do not work we then try to refresh all the tokens as usual. Also AuthSessionCertImpl and AuthSessionImpl have been merged since they were executing the same code
f8d939a to
6054612
Compare
688b8c5 to
24fead9
Compare
symphony-youri
approved these changes
Jan 14, 2022
| maxIntervalMillis: 10000 | ||
|
|
||
|
|
||
| commonJwt: |
Contributor
There was a problem hiding this comment.
let's maybe not even document it for now? as it is not fully supported (OBO, agent)
…support. It will be added back later.
This file contains hidden or 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
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.
Ticket
#617
Description
Goal of this implementation is to be able to start using the common JWT to call pod public APIs.
First of all the usage of common jwt can be configured by a configuration property in the application.yaml file.
When the feature is enabled, the Authorization token will be used as header for each Pod call instead of the sessionToken.
To do so, we are programmatically enforcing a new Authentication scheme (OAuthorization) which is in charge of adding the Authorization token in the headers and removing the sessionToken when the feature is enabled.
Being the common jwt token expiration very low respect to the sessionToken, the OAuthSession is going to make sure that before making any Api call with the new Authorization scheme, the common jwt is up to date and in case it expires it is going to be refreshed before.
Checklist
Closes #617