diff --git a/.gitignore b/.gitignore index 2f6c052..3445633 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ app/.classpath app/.project app/.settings +java/.gradle +java/app/build +java/gradle \ No newline at end of file diff --git a/java/app/src/main/java/org/vss/auth/JwtAuthorizer.java b/java/app/src/main/java/org/vss/auth/JwtAuthorizer.java index 9175c30..f5bdab5 100644 --- a/java/app/src/main/java/org/vss/auth/JwtAuthorizer.java +++ b/java/app/src/main/java/org/vss/auth/JwtAuthorizer.java @@ -35,6 +35,10 @@ public JwtAuthorizer(String pemFormatRSAPublicKey) throws Exception { this.verifier = JWT.require(algorithm).build(); } + public JwtAuthorizer() throws Exception { + this(System.getenv("vss.jwt.pubkey")); + } + @Override public AuthResponse verify(HttpHeaders headers) throws AuthException { diff --git a/java/app/src/main/java/org/vss/guice/BaseModule.java b/java/app/src/main/java/org/vss/guice/BaseModule.java index 94c169a..0dbc2c3 100644 --- a/java/app/src/main/java/org/vss/guice/BaseModule.java +++ b/java/app/src/main/java/org/vss/guice/BaseModule.java @@ -16,6 +16,7 @@ import org.vss.auth.Authorizer; import org.vss.auth.NoopAuthorizer; import org.vss.impl.postgres.PostgresBackendImpl; +import org.vss.auth.JwtAuthorizer; public class BaseModule extends AbstractModule { @@ -24,8 +25,8 @@ protected void configure() { // Provide PostgresBackend as default implementation for KVStore. bind(KVStore.class).to(PostgresBackendImpl.class).in(Singleton.class); - // Default to Noop Authorizer. - bind(Authorizer.class).to(NoopAuthorizer.class).in(Singleton.class); + // Use JWT Authorizor. + bind(Authorizer.class).to(JwtAuthorizer.class).in(Singleton.class); } @Provides diff --git a/java/docker-compose.yml b/java/docker-compose.yml index bd6f464..c032f97 100644 --- a/java/docker-compose.yml +++ b/java/docker-compose.yml @@ -21,7 +21,8 @@ services: depends_on: - postgres ports: - - "8080:8080" + # prevent conflict with Alby Hub in development + - "8090:8080" networks: - app-network