-
Notifications
You must be signed in to change notification settings - Fork 69
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
APP-2846: Obo Certificate Authentication #218
Conversation
Create AuthSessionOboCerImpl implements the AuthSession to represent a authsession after a bot authenticate OBO user OboAuthenticatorCertImpl implements the OboAuthenticator for handling the Obo authentication stuff for a bot using Certificate In ApiClientFactory, create a method ApiClientFactory#getExtAppSessionAuthClient to get a dedicated sessionauth client for extension app authentication configured with the keystore of the extension app and the password In AuthenticatorFactory, check if the extension app is configured with certificate or not. If yes, AuthenticatorFactory#getOboAuthenticator returns an OboAuthenticatorCertImpl, otherwise, returns an OboAuthenticatorRsaImpl Unittest added Javadoc added
symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/impl/AuthSessionOboCerImpl.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/impl/AuthSessionOboCerImpl.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/client/ApiClientFactory.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/config/model/BdkExtAppConfig.java
Outdated
Show resolved
Hide resolved
...ony-bdk-core/src/test/java/com/symphony/bdk/core/auth/impl/OboAuthenticatorCertImplTest.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/impl/AuthSessionOboCerImpl.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/client/ApiClientFactory.java
Outdated
Show resolved
Hide resolved
try { | ||
OboAuthResponse oboAuthResponse = this.authenticationApi.v1AppUsernameUsernameAuthenticatePost(username, appSessionToken); | ||
return oboAuthResponse.getSessionToken(); | ||
} catch (ApiException e) { |
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.
Could we find a way to extract this logic ? Only difference is the message in the AuthUnauthorizedException
.
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.
I think we are fine with the current code. It's not a big block of code at all. 🤔
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.
LGTM 👍
...ony-bdk-core/src/test/java/com/symphony/bdk/core/auth/impl/OboAuthenticatorCertImplTest.java
Outdated
Show resolved
Hide resolved
|
||
private String username; | ||
private String privateKeyPath; | ||
private String certificatePath; |
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.
in term of configuration should'nt we have something like:
username: "mybot"
certificate:
path:
password
repeating the same prefix is often the sign that a sub structure should be used
but then to be consistent you would wonder if privateKeyPath should a privateKey item with a path sub item....
could we have other settings for a private key?
import com.symphony.bdk.core.auth.OboAuthenticator; | ||
import com.symphony.bdk.core.auth.exception.AuthUnauthorizedException; | ||
|
||
import lombok.NonNull; |
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.
do we have that NonNull annotation on purpose (vs the javax one)?
if so maybe we should explicit when we use that one vs the other
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.
Import issue I guess, should be javax.annotation.Nonnull
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.
NonNull from lombok actually helps us validate the configuration which could be useful here
(Although we perhaps want to provider our own validation for more complex use cases and checks or use javax validation)
protected String privateKeyPath; | ||
protected String certificatePath; | ||
protected String certificatePassword; |
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.
Following @symphony-youri's comment below, I also think that we should change our configuration model to:
bot:
username: 'my-bot'
rsa:
privateKeyPath:
privateKeyContent:
certificate:
path:
password:
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.
but then should it be:
bot:
username: 'my-bot'
rsa:
privateKey:
path: / or content:
certificate:
path:
password:
😅
or maybe just rsa.path / rsa.content ? (and by the way is it really rsa or the notion of public/private keys? might be another algorithm)
so maybe just privateKey.path / privateKey.content?
Using line breaks to split different phases of the test
Create AuthSessionOboCerImpl implements the AuthSession to represent
a authsession after a bot authenticate OBO user
OboAuthenticatorCertImpl implements the OboAuthenticator for handling
the Obo authentication stuff for a bot using Certificate
In ApiClientFactory, create a method ApiClientFactory#getExtAppSessionAuthClient
to get a dedicated sessionauth client for extension app authentication configured
with the keystore of the extension app and the password
In AuthenticatorFactory, check if the extension app is configured with
certificate or not. If yes, AuthenticatorFactory#getOboAuthenticator returns
an OboAuthenticatorCertImpl, otherwise, returns an OboAuthenticatorRsaImpl
Unittest added
Javadoc added