Skip to content

Commit

Permalink
Address some comment 1
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Aug 22, 2023
1 parent 8a96cab commit d79973c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void shouldNotAuthenticateForUsingOBOTokenToAccessOBOEndpoint() {
Header adminOboAuthHeader = new BasicHeader("Authorization", "Bearer " + oboToken);

try (TestRestClient client = cluster.getRestClient(adminOboAuthHeader)) {
TestRestClient.HttpResponse response = client.getOBOTokenFromOboEndpoint(OBO_REASON, adminOboAuthHeader);
TestRestClient.HttpResponse response = client.getOnBehalfOfToken(OBO_REASON, adminOboAuthHeader);
response.assertStatusCode(401);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public HttpResponse getAuthInfo(Header... headers) {
return executeRequest(new HttpGet(getHttpServerUri() + "/_opendistro/_security/authinfo?pretty"), headers);
}

public HttpResponse getOBOTokenFromOboEndpoint(String jsonData, Header... headers) {
public HttpResponse getOnBehalfOfToken(String jsonData, Header... headers) {
try {
HttpPost httpPost = new HttpPost(new URIBuilder(getHttpServerUri() + "/_plugins/_security/api/user/onbehalfof?pretty").build());
httpPost.setEntity(toStringEntity(jsonData));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public HTTPJwtAuthenticator(final Settings settings, final Path configPath) {
super();

String signingKey = settings.get("signing_key");
JwtParser _jwtParser = keyUtil.keyAlgorithmCheck(signingKey, log);
JwtParser _jwtParser = keyUtil.createJwtParserFromSigningKey(signingKey, log);

jwtUrlParameter = settings.get("jwt_url_parameter");
jwtHeaderName = settings.get("jwt_header", HttpHeaders.AUTHORIZATION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ public static void setClusterService(ClusterService clusterService) {
cs = clusterService;
}

public static ClusterService getClusterNameString() {
public static ClusterService getClusterName() {
return cs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public OnBehalfOfAuthenticator(Settings settings) {
}

private JwtParser initParser(final String signingKey) {
JwtParser _jwtParser = keyUtil.keyAlgorithmCheck(signingKey, log);
JwtParser _jwtParser = keyUtil.createJwtParserFromSigningKey(signingKey, log);

if (_jwtParser == null) {
throw new RuntimeException("Unable to find on behalf of authenticator signing key");
Expand Down Expand Up @@ -211,7 +211,7 @@ private AuthCredentials extractCredentials0(final RestRequest request) {
}

final String issuer = claims.getIssuer();
final String clusterID = OpenSearchSecurityPlugin.getClusterNameString().getClusterName().value();
final String clusterID = OpenSearchSecurityPlugin.getClusterName().getClusterName().value();
if (!issuer.equals(clusterID)) {
log.error("This issuer of this OBO does not match the current cluster identifier");
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/opensearch/security/util/keyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class keyUtil {

public static JwtParser keyAlgorithmCheck(final String signingKey, final Logger log) {
public static JwtParser createJwtParserFromSigningKey(final String signingKey, final Logger log) {
final SecurityManager sm = System.getSecurityManager();

JwtParser jwtParser = null;
Expand Down

0 comments on commit d79973c

Please sign in to comment.