-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for pluggable Authorizer, default to NoopAuthorizer
- Loading branch information
Showing
18 changed files
with
196 additions
and
88 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
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
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
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,10 @@ | ||
package org.vss.auth; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class AuthResponse { | ||
private String userToken; | ||
} |
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 @@ | ||
package org.vss.auth; | ||
|
||
import jakarta.ws.rs.core.HttpHeaders; | ||
import org.vss.exception.AuthException; | ||
|
||
// Interface for authorizer that is run before every request. | ||
public interface Authorizer { | ||
AuthResponse verify(HttpHeaders headers) throws AuthException; | ||
} |
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,13 @@ | ||
package org.vss.auth; | ||
|
||
import jakarta.ws.rs.core.HttpHeaders; | ||
import org.vss.exception.AuthException; | ||
|
||
// A no-operation authorizer, that lets any user-request go through. | ||
public class NoopAuthorizer implements Authorizer { | ||
private static String UNAUTHENTICATED_USER = "unauth-user"; | ||
@Override | ||
public AuthResponse verify(HttpHeaders headers) throws AuthException { | ||
return new AuthResponse( UNAUTHENTICATED_USER); | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
app/src/main/java/org/vss/impl/postgres/sql/v0_create_vss_db.sql
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
CREATE TABLE vss_db ( | ||
user_token character varying(120) NOT NULL CHECK (user_token <> ''), | ||
store_id character varying(120) NOT NULL CHECK (store_id <> ''), | ||
key character varying(600) NOT NULL, | ||
value bytea NULL, | ||
version bigint NOT NULL, | ||
created_at TIMESTAMP WITH TIME ZONE, | ||
last_updated_at TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (store_id, key) | ||
PRIMARY KEY (user_token, store_id, key) | ||
); |
Oops, something went wrong.