Skip to content

Commit 2f5ee7f

Browse files
authored
Make OAuth scope optional (strimzi#30)
* Make scope optional Signed-off-by: klalafaryan <konstantin.lalafaryan@blacklane.com> * Add comment Signed-off-by: klalafaryan <konstantin.lalafaryan@blacklane.com> * Improve the comment Signed-off-by: klalafaryan <konstantin.lalafaryan@blacklane.com>
1 parent 91c5683 commit 2f5ee7f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

oauth-common/src/main/java/io/strimzi/kafka/oauth/common/OAuthAuthenticator.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,9 @@ private static TokenInfo post(URI tokenEndpointUri, SSLSocketFactory socketFacto
102102
throw new IllegalStateException("Invalid response from authorization server: no expires_in");
103103
}
104104

105+
// Some OAuth2 authorization servers don't provide scope in this level,
106+
// therefore we don't need to make it mandatory
105107
JsonNode scope = result.get("scope");
106-
if (scope == null) {
107-
throw new IllegalStateException("Invalid response from authorization server: no scope");
108-
}
109108

110109
if (isJWT) {
111110
// try introspect token
@@ -116,7 +115,7 @@ private static TokenInfo post(URI tokenEndpointUri, SSLSocketFactory socketFacto
116115
}
117116
}
118117

119-
return new TokenInfo(token.asText(), scope.asText(), "undefined", now, now + expiresIn.asLong() * 1000L);
118+
return new TokenInfo(token.asText(), scope != null ? scope.asText() : null, "undefined", now, now + expiresIn.asLong() * 1000L);
120119
}
121120

122121
public static String base64encode(String value) {

0 commit comments

Comments
 (0)