Skip to content

Commit

Permalink
More generic Authorization Code flow
Browse files Browse the repository at this point in the history
Remove the hard dependency to the google cloud IAM and use the generic
OAuth2 Authorization Code Flow.
Configuration now happens completely through ENV variables.

Also removed the check if the user is still in the organization, because
it's not part of the oauth2 standard.
although it is a valid check and should be considered in the future.
  • Loading branch information
pschmidt88 committed May 7, 2020
1 parent 0218c58 commit c59caba
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 282 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.secrets/
.vertx/
build/
.env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENV AUTH_CACHE_TTL "300"
ENV BIND_PORT "8080"
ENV CLIENT_ID "REPLACE_ME"
ENV CLIENT_SECRET "REPLACE_ME"
ENV CLOUD_IAM_AUTH_ENABLED "false"
ENV CLOUD_IAM_AUTH_ENABLED "true"
ENV JWT_REQUIRES_MEMBERSHIP_VERIFICATION "true"
ENV KEYSTORE_PATH "keystore.jceks"
ENV KEYSTORE_PASS "safe#passw0rd!"
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.1'
id "com.diffplug.gradle.spotless" version "3.29.0"
}

group 'com.travelaudience.nexus'
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/travelaudience/nexus/proxy/AccessToken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.travelaudience.nexus.proxy;

import com.google.api.client.json.jackson2.*;
import com.google.api.client.json.webtoken.*;
import java.io.*;

public class AccessToken {
private final String rawToken;

public AccessToken(String token) {
rawToken = token;
}

public String principal() throws IOException {
JsonWebSignature jws = JsonWebSignature
.parser(JacksonFactory.getDefaultInstance())
.setPayloadClass(PayloadWithEmail.class)
.parse(rawToken);
return ((PayloadWithEmail) jws.getPayload()).getEmail();
}
}

This file was deleted.

Loading

0 comments on commit c59caba

Please sign in to comment.