-
Notifications
You must be signed in to change notification settings - Fork 135
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
Adapt single tenant token keys requests #1407
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: liga-oz <[email protected]>
Signed-off-by: liga-oz <[email protected]>
…oken_keys_requests
@@ -94,11 +94,21 @@ private PublicKey fetchPublicKey(Token token, JwtSignatureAlgorithm algorithm) t | |||
return tokenKeyService.getPublicKey(algorithm, keyId, uri, params); | |||
} | |||
|
|||
private String composeZidQueryParameter(Token token) { | |||
String composeQueryParameters(Token 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.
How about one of the following alternatives that, albeit not shorter, are probably more expressive / easier to maintain? Too much overhead?
String composeQueryParameters(Token token) {
String query =
Map.of("zid", Objects.requireNonNullElse(token.getAppTid(), ""),
"client_id", Objects.requireNonNullElse(configuration.getClientId(), ""))
.entrySet().stream()
.filter(entry -> !entry.getValue().isBlank())
.map(entry -> entry.getKey() + "=" + entry.getValue())
.sorted()
.collect(Collectors.joining("&", "?", ""));
query = Objects.equals("?", query) ? "" : query;
LOGGER.debug("Composed query parameter for token keys: {}", query);
return query;
}
String composeQueryParameters(Token token) {
List<Map.Entry<String, String>> parameters =
Map.of("zid", Objects.requireNonNullElse(token.getAppTid(), ""),
"client_id", Objects.requireNonNullElse(configuration.getClientId(), ""))
.entrySet().stream()
.filter(entry -> !entry.getValue().isBlank())
.collect(Collectors.toList());
String query = parameters.isEmpty()
? ""
: parameters.stream()
.map(entry -> entry.getKey() + "=" + entry.getValue())
.sorted()
.collect(Collectors.joining("&", "?", ""));
LOGGER.debug("Composed query parameter for token keys: {}", query);
return query;
}
String zid = token.getAppTid(); | ||
String clientId = token.getClientId(); |
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 must be changed to
configuration.getClientId()
}) | ||
void composeQueryParams(String clientId, String appTid, String query) { | ||
Token tokenMock = Mockito.mock(Token.class); | ||
Mockito.when(tokenMock.getClientId()).thenReturn(clientId); |
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 must be changed to
Mockito.when(mockConfiguration.getClientId()).thenReturn(clientId);
Signed-off-by: liga-oz <[email protected]>
Signed-off-by: liga-oz <[email protected]>
No description provided.