Skip to content

Commit

Permalink
Merge pull request #1 from getAlby/feat/jwt-authorizor
Browse files Browse the repository at this point in the history
feat: JWT Authorizor
  • Loading branch information
rolznz authored Dec 10, 2024
2 parents 914a6ac + df26f2b commit ab8c1ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ app/.classpath
app/.project
app/.settings

java/.gradle
java/app/build
java/gradle
4 changes: 4 additions & 0 deletions java/app/src/main/java/org/vss/auth/JwtAuthorizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
5 changes: 3 additions & 2 deletions java/app/src/main/java/org/vss/guice/BaseModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion java/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ services:
depends_on:
- postgres
ports:
- "8080:8080"
# prevent conflict with Alby Hub in development
- "8090:8080"
networks:
- app-network

Expand Down

0 comments on commit ab8c1ee

Please sign in to comment.