-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
419 changed files
with
4,272 additions
and
3,922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Checkstyle Action | ||
on: pull_request | ||
|
||
jobs: | ||
checkstyle_job: | ||
runs-on: ubuntu-latest | ||
name: Checkstyle Job | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Run check style | ||
uses: nikitasavinov/checkstyle-action@master | ||
with: | ||
level: 'error' | ||
fail_on_error: 'true' | ||
github_token: ${{ secrets.GH_PAT }} | ||
reporter: 'github-pr-check' | ||
filter_mode: 'file' | ||
checkstyle_config: checkstyle.xml | ||
tool_name: 'reviewdog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> | ||
<module name="Checker"> | ||
<property name="fileExtensions" value="java" /> | ||
<module name="LineLength"> | ||
<property name="max" value="400" /> | ||
</module> | ||
<module name="TreeWalker"> | ||
<module name="SuppressionCommentFilter"> | ||
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ?([\w\|]+)" /> | ||
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ?([\w\|]+)" /> | ||
<property name="checkFormat" value="$1" /> | ||
</module> | ||
<module name="AnnotationUseStyle"> | ||
<property name="elementStyle" value="ignore" /> | ||
</module> | ||
<module name="MissingOverride"> | ||
<property name="javaFiveCompatibility" value="true" /> | ||
</module> | ||
<module name="EmptyBlock"> | ||
<property name="option" value="text" /> | ||
<property name="tokens" value="LITERAL_CATCH" /> | ||
</module> | ||
<module name="EmptyBlock"> | ||
<property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, STATIC_INIT" /> | ||
<property name="option" value="text" /> | ||
</module> | ||
<module name="LeftCurly" /> | ||
<module name="NeedBraces" /> | ||
<module name="RightCurly" /> | ||
<module name="HideUtilityClassConstructor" /> | ||
<module name="EmptyStatement" /> | ||
<module name="EqualsHashCode" /> | ||
<module name="InnerAssignment" /> | ||
<module name="SimplifyBooleanExpression" /> | ||
<module name="SimplifyBooleanReturn" /> | ||
<module name="StringLiteralEquality" /> | ||
<module name="IllegalThrows"> | ||
<property name="illegalClassNames" value="java.lang.Error, java.lang.RuntimeException" /> | ||
</module> | ||
<module name="RegexpSinglelineJava"> | ||
<property name="format" value="^\t* "/> | ||
<property name="message" value="Indent must use tab characters"/> | ||
<property name="ignoreComments" value="true"/> | ||
</module> | ||
<module name="ExplicitInitialization" /> | ||
<module name="DefaultComesLast" /> | ||
<module name="FallThrough" /> | ||
<module name="MultipleVariableDeclarations" /> | ||
<module name="UnnecessaryParentheses" /> | ||
<module name="RedundantImport" /> | ||
<module name="UnusedImports"> | ||
<property name="processJavadoc" value="true" /> | ||
</module> | ||
<module name="UpperEll" /> | ||
<module name="ArrayTypeStyle" /> | ||
<module name="RedundantModifier"> | ||
<property name="tokens" value="METHOD_DEF,VARIABLE_DEF,ANNOTATION_FIELD_DEF,INTERFACE_DEF,CLASS_DEF,ENUM_DEF" /> | ||
</module> | ||
<module name="ClassTypeParameterName" /> | ||
<module name="LocalFinalVariableName" /> | ||
<module name="LocalVariableName" /> | ||
<module name="MemberName" /> | ||
<module name="MethodName"> | ||
<property name="format" value="^(([A-Z][A-Z0-9]+)|([a-z][a-z0-9]*))([A-Z][a-z0-9]*)*" /> | ||
</module> | ||
<module name="MethodTypeParameterName" /> | ||
<module name="PackageName" /> | ||
<module name="ParameterName" /> | ||
<module name="StaticVariableName" /> | ||
<module name="TypeName" /> | ||
<module name="GenericWhitespace" /> | ||
<module name="EmptyForInitializerPad" /> | ||
<module name="EmptyForIteratorPad" /> | ||
<module name="MethodParamPad" /> | ||
<module name="NoWhitespaceAfter"> | ||
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS" /> | ||
</module> | ||
<module name="NoWhitespaceBefore"> | ||
<property name="allowLineBreaks" value="true" /> | ||
<property name="tokens" value="SEMI,POST_DEC,POST_INC" /> | ||
</module> | ||
<module name="OperatorWrap" /> | ||
<module name="ParenPad" /> | ||
<module name="TypecastParenPad" /> | ||
<module name="WhitespaceAfter"> | ||
<property name="tokens" value="COMMA,SEMI,TYPECAST" /> | ||
</module> | ||
<module name="WhitespaceAround" /> | ||
</module> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" | ||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> | ||
<module name="Checker"> | ||
<property name="fileExtensions" value="java"/> | ||
|
||
<module name="FileTabCharacter"> | ||
<property name="fileExtensions" value="java"/> | ||
</module> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,38 +41,27 @@ | |
public class AuthenticationFilter implements ContainerRequestFilter { | ||
|
||
@Inject | ||
@AuthenticatedUser | ||
Event<Person> userAuthenticatedEvent; | ||
@AuthenticatedUser Event<Person> userAuthenticatedEvent; | ||
|
||
@Inject | ||
AuthenticationService authenticationService; | ||
@Inject AuthenticationService authenticationService; | ||
|
||
@Inject | ||
PersonDAO personDAO; | ||
@Inject PersonDAO personDAO; | ||
|
||
@Inject | ||
AllianceMemberDAO allianceMemberDAO; | ||
@Inject AllianceMemberDAO allianceMemberDAO; | ||
|
||
@Inject | ||
PersonService personService; | ||
@Inject PersonService personService; | ||
|
||
@Inject | ||
PersonUniqueIdHelper loggedInPersonUniqueId; | ||
@Inject PersonUniqueIdHelper loggedInPersonUniqueId; | ||
|
||
@ConfigProperty(name = "okta.authentication") | ||
Instance<Boolean> okta_auth; | ||
@ConfigProperty(name = "okta.authentication") Instance<Boolean> oktaAuth; | ||
|
||
@ConfigProperty(name = "okta.url") | ||
Instance<String> okta_url; | ||
@ConfigProperty(name = "okta.url") Instance<String> oktaUrl; | ||
|
||
@ConfigProperty(name = "okta.client.id") | ||
Instance<String> client_id; | ||
@ConfigProperty(name = "okta.client.id") Instance<String> clientId; | ||
|
||
@ConfigProperty(name = "okta.client.secret") | ||
Instance<String> client_secret; | ||
@ConfigProperty(name = "okta.client.secret") Instance<String> clientSecret; | ||
|
||
@ConfigProperty(name = "okta.api.token") | ||
Instance<String> api_token; | ||
@ConfigProperty(name = "okta.api.token") Instance<String> apiToken; | ||
|
||
// private static final String REALM = "AGR"; | ||
private static final String AUTHENTICATION_SCHEME = "Bearer"; | ||
|
@@ -86,8 +75,8 @@ public void filter(ContainerRequestContext requestContext) throws IOException { | |
// Testing) | ||
// if okta_auth is on and we have okta_creds validate(token), else fail | ||
|
||
if (okta_auth.get()) { | ||
if (!okta_url.get().equals("\"\"") && !client_id.get().equals("\"\"") && !client_secret.get().equals("\"\"") && !api_token.get().equals("\"\"")) { | ||
if (oktaAuth.get()) { | ||
if (!oktaUrl.get().equals("\"\"") && !clientId.get().equals("\"\"") && !clientSecret.get().equals("\"\"") && !apiToken.get().equals("\"\"")) { | ||
|
||
String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION); | ||
|
||
|
@@ -97,20 +86,20 @@ public void filter(ContainerRequestContext requestContext) throws IOException { | |
String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim(); | ||
|
||
Person person = null; | ||
|
||
try { | ||
Jwt jsonWebToken = authenticationService.verifyToken(token); | ||
|
||
if(person == null) { | ||
if (person == null) { | ||
person = validateUserToken(jsonWebToken); | ||
} | ||
if(person == null) { | ||
if (person == null) { | ||
person = validateAdminToken(jsonWebToken); | ||
} | ||
} catch (JwtVerificationException e) { | ||
person = personService.findPersonByApiToken(token); | ||
} | ||
|
||
if (person != null) { | ||
userAuthenticatedEvent.fire(person); | ||
} else { | ||
|
@@ -152,12 +141,12 @@ private void loginDevUser() { | |
|
||
// Check Okta(token), Check DB ApiToken(token), else return null | ||
private Person validateUserToken(Jwt jsonWebToken) { | ||
|
||
String oktaUserId = (String) jsonWebToken.getClaims().get("uid"); // User Id | ||
if(oktaUserId != null && oktaUserId.length() > 0) { | ||
|
||
if (oktaUserId != null && oktaUserId.length() > 0) { | ||
String oktaEmail = (String) jsonWebToken.getClaims().get("sub"); // Subject Id | ||
|
||
Person authenticatedUser = personService.findPersonByOktaEmail(oktaEmail); | ||
|
||
if (authenticatedUser != null) { | ||
|
@@ -186,27 +175,27 @@ private Person validateUserToken(Jwt jsonWebToken) { | |
return person; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private Person validateAdminToken(Jwt jsonWebToken) { | ||
|
||
String oktaClientId = (String) jsonWebToken.getClaims().get("cid"); // Client Id | ||
if(oktaClientId != null && oktaClientId.length() > 0) { | ||
|
||
if (oktaClientId != null && oktaClientId.length() > 0) { | ||
|
||
Person authenticatedUser = personService.findPersonByOktaId(oktaClientId); | ||
|
||
if (authenticatedUser != null) { | ||
return authenticatedUser; | ||
} | ||
|
||
Log.info("Making OKTA call to get app info: "); | ||
|
||
Application app = getOktaClient(oktaClientId); | ||
if(app != null) { | ||
|
||
if (app != null) { | ||
log.debug("OKTA Authentication for Admin user via token"); | ||
String adminEmail = "[email protected]"; | ||
Person person = new Person(); | ||
|
@@ -224,14 +213,13 @@ private Person validateAdminToken(Jwt jsonWebToken) { | |
return null; | ||
} | ||
|
||
|
||
private User getOktaUser(String oktaId) { | ||
Client client = Clients.builder().setOrgUrl(okta_url.get()).setClientId(client_id.get()).setClientCredentials(new TokenClientCredentials(api_token.get())).build(); | ||
Client client = Clients.builder().setOrgUrl(oktaUrl.get()).setClientId(clientId.get()).setClientCredentials(new TokenClientCredentials(apiToken.get())).build(); | ||
return client.getUser(oktaId); | ||
} | ||
|
||
private Application getOktaClient(String applicationId) { | ||
Client client = Clients.builder().setOrgUrl(okta_url.get()).setClientId(client_id.get()).setClientCredentials(new TokenClientCredentials(api_token.get())).build(); | ||
Client client = Clients.builder().setOrgUrl(oktaUrl.get()).setClientId(clientId.get()).setClientCredentials(new TokenClientCredentials(apiToken.get())).build(); | ||
return client.getApplication(applicationId); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.