Skip to content

Commit

Permalink
fixed build and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
AnujaVane committed Jul 9, 2020
1 parent a14d4b6 commit 1da5201
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public KetoAuthorizationProvider(Map<String, Object> options) {
throw new IllegalArgumentException("Cannot pass empty or null options to KetoAuth");
}
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath((String)options.get("basePath"));
defaultClient.setBasePath((String) options.get("basePath"));
this.apiInstance = new EnginesApi(defaultClient);
this.options = options;
}
Expand All @@ -59,9 +59,8 @@ public KetoAuthorizationProvider(Map<String, Object> options) {
* @return AuthorizationResult result of authorization query
*/
public AuthorizationResult checkAccess(String project, Authentication authentication) {
String subject = (String)this.options.get("subject");
if ((subject == null) || (subject.isEmpty()))
subject = "email";
String subject = (String) this.options.get("subject");
if ((subject == null) || (subject.isEmpty())) subject = "email";
String subjectValue = getSubjectFromAuth(authentication, subject);
try {
// Get all roles from Keto
Expand Down Expand Up @@ -91,7 +90,7 @@ public AuthorizationResult checkAccess(String project, Authentication authentica
}
// Could not determine project membership, deny access.
return AuthorizationResult.failed(
String.format("Access denied to project %s for user %s", project, email));
String.format("Access denied to project %s for user %s", project, subjectValue));
}

/**
Expand All @@ -104,7 +103,7 @@ public AuthorizationResult checkAccess(String project, Authentication authentica
private String getSubjectFromAuth(Authentication authentication, String subject) {
Jwt principle = ((Jwt) authentication.getPrincipal());
Map<String, Object> claims = principle.getClaims();
String subjectValue = (String)claims.get(subject);
String subjectValue = (String) claims.get(subject);

if (subjectValue.isEmpty()) {
throw new IllegalStateException(String.format("JWT does not have a valid %s.", subject));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public static class AuthorizationProperties {
private String provider;

// K/V options to initialize the provider with
private Map<String, String> options;
private Map<String, Object> options;
}
}

0 comments on commit 1da5201

Please sign in to comment.