-
Notifications
You must be signed in to change notification settings - Fork 3
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
Added OkHttpClient API call for auth check #9
Added OkHttpClient API call for auth check #9
Conversation
builder.header("Authorization", "Bearer " + msClientAuthTokenService.getAccessToken()); | ||
String token = msClientAuthTokenService.getAccessToken(); | ||
logger.debug("Retrieved token"); | ||
DecodedJWT jwt = JWT.decode(token); |
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.
is this JWT actually used anywhere or logged? might be worth highlighting that this is optional (and the dependency that is needed for this)
@@ -38,6 +55,8 @@ public class MsRetrofitWrapper { | |||
*/ | |||
public MsRetrofitWrapper(String url, Level logLevel) throws Exception { | |||
this.msClientAuthTokenService = new MsClientAuthTokenService(MICROPROFILE_CONFIG_SERVICE); | |||
this.url = url; | |||
this.logLevel = logLevel; |
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.
Is this needed on the constructor? is there any way people can omit having to set this explicitly and instead do via microprofile config? (e.g. in Spring, you would rarely never set a log level directly in code)
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.
Also, is this like a debug/info/warn style level or is it more detailed/specific?
@@ -94,4 +115,16 @@ public Retrofit getRetrofit() { | |||
public <T> T createService(Class<T> serviceInterface) { | |||
return this.getRetrofit().create(serviceInterface); | |||
} | |||
|
|||
public void checkAuthorisation(String apiEndpoint) throws IOException { |
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.
Javadoc on this method to explain what it's for
…samples/python/rest/black-24.10.0 pip-rest: bump black from 24.3.0 to 24.10.0 in /client-samples/python/rest
Added API call to help check authorisation. Don't need to configure retrofit service as just uses an OkHttpClient to call the API and print response code and body.
Added logging debugs for JWTs. They are also decoded using JWT library if more information is needed.
In the tests, changed the MOCK_TOKEN to a fake JWT that can be decoded.