@Test public void authScheme_getAuthenticationScheme_userPool() { AwsProxySecurityContext context = new AwsProxySecurityContext(null, REQUEST_COGNITO_USER_POOL); assertNotNull(context.getAuthenticationScheme()); assertEquals(AUTH_SCHEME_COGNITO_POOL, context.getAuthenticationScheme()); }
@Override public String getAuthenticationScheme() { switch (event.getRequestSource()) { case API_GATEWAY: if (event.getRequestContext().getAuthorizer() != null && event.getRequestContext().getAuthorizer().getClaims() != null && event.getRequestContext().getAuthorizer().getClaims().getSubject() != null) { return AUTH_SCHEME_COGNITO_POOL; } else if (event.getRequestContext().getAuthorizer() != null) { return AUTH_SCHEME_CUSTOM; } else if (event.getRequestContext().getIdentity().getAccessKey() != null) { return AUTH_SCHEME_AWS_IAM; } else { return null; } case ALB: if (event.getMultiValueHeaders().containsKey(ALB_ACESS_TOKEN_HEADER)) { return AUTH_SCHEME_CUSTOM; } } return null; }
AwsProxySecurityContext implements SecurityContext { @Override public String getAuthenticationScheme() { switch (event.getRequestSource()) { case API_GATEWAY: if (event.getRequestContext().getAuthorizer() != null && event.getRequestContext().getAuthorizer().getClaims() != null && event.getRequestContext().getAuthorizer().getClaims().getSubject() != null) { return AUTH_SCHEME_COGNITO_POOL; } else if (event.getRequestContext().getAuthorizer() != null) { return AUTH_SCHEME_CUSTOM; } else if (event.getRequestContext().getIdentity().getAccessKey() != null) { return AUTH_SCHEME_AWS_IAM; } else { return null; } case ALB: if (event.getMultiValueHeaders().containsKey(ALB_ACESS_TOKEN_HEADER)) { return AUTH_SCHEME_CUSTOM; } } return null; } }
AwsProxySecurityContext implements SecurityContext { @Override public String getAuthenticationScheme() { switch (event.getRequestSource()) { case API_GATEWAY: if (event.getRequestContext().getAuthorizer() != null && event.getRequestContext().getAuthorizer().getClaims() != null && event.getRequestContext().getAuthorizer().getClaims().getSubject() != null) { return AUTH_SCHEME_COGNITO_POOL; } else if (event.getRequestContext().getAuthorizer() != null) { return AUTH_SCHEME_CUSTOM; } else if (event.getRequestContext().getIdentity().getAccessKey() != null) { return AUTH_SCHEME_AWS_IAM; } else { return null; } case ALB: if (event.getMultiValueHeaders().containsKey(ALB_ACESS_TOKEN_HEADER)) { return AUTH_SCHEME_CUSTOM; } } return null; } AwsProxySecurityContext(final Context lambdaContext, final AwsProxyRequest event); }
AwsProxySecurityContext implements SecurityContext { @Override public String getAuthenticationScheme() { switch (event.getRequestSource()) { case API_GATEWAY: if (event.getRequestContext().getAuthorizer() != null && event.getRequestContext().getAuthorizer().getClaims() != null && event.getRequestContext().getAuthorizer().getClaims().getSubject() != null) { return AUTH_SCHEME_COGNITO_POOL; } else if (event.getRequestContext().getAuthorizer() != null) { return AUTH_SCHEME_CUSTOM; } else if (event.getRequestContext().getIdentity().getAccessKey() != null) { return AUTH_SCHEME_AWS_IAM; } else { return null; } case ALB: if (event.getMultiValueHeaders().containsKey(ALB_ACESS_TOKEN_HEADER)) { return AUTH_SCHEME_CUSTOM; } } return null; } AwsProxySecurityContext(final Context lambdaContext, final AwsProxyRequest event); Context getLambdaContext(); AwsProxyRequest getEvent(); @Override Principal getUserPrincipal(); @Override boolean isUserInRole(String role); @Override boolean isSecure(); @Override String getAuthenticationScheme(); }
AwsProxySecurityContext implements SecurityContext { @Override public String getAuthenticationScheme() { switch (event.getRequestSource()) { case API_GATEWAY: if (event.getRequestContext().getAuthorizer() != null && event.getRequestContext().getAuthorizer().getClaims() != null && event.getRequestContext().getAuthorizer().getClaims().getSubject() != null) { return AUTH_SCHEME_COGNITO_POOL; } else if (event.getRequestContext().getAuthorizer() != null) { return AUTH_SCHEME_CUSTOM; } else if (event.getRequestContext().getIdentity().getAccessKey() != null) { return AUTH_SCHEME_AWS_IAM; } else { return null; } case ALB: if (event.getMultiValueHeaders().containsKey(ALB_ACESS_TOKEN_HEADER)) { return AUTH_SCHEME_CUSTOM; } } return null; } AwsProxySecurityContext(final Context lambdaContext, final AwsProxyRequest event); Context getLambdaContext(); AwsProxyRequest getEvent(); @Override Principal getUserPrincipal(); @Override boolean isUserInRole(String role); @Override boolean isSecure(); @Override String getAuthenticationScheme();  }