-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from PolicyEngine/feat/add_auth
Add user authentication
- Loading branch information
Showing
11 changed files
with
87 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ dist/* | |
**/*.rdb | ||
**/*.h5 | ||
**/*.csv.gz | ||
.env |
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,4 @@ | ||
- bump: minor | ||
changes: | ||
added: | ||
- Added authentication via auth0 |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
FROM anthvolk/policyengine-api-light:latest | ||
ENV GOOGLE_APPLICATION_CREDENTIALS .gac.json | ||
ENV AUTH0_ADDRESS_NO_DOMAIN .address | ||
ENV AUTH0_AUDIENCE_NO_DOMAIN .audience | ||
ENV AUTH0_TEST_TOKEN_NO_DOMAIN .test-token | ||
ADD . /app | ||
RUN cd /app && make install && make test | ||
CMD ./start.sh |
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,18 @@ | ||
import json | ||
from urllib.request import urlopen | ||
|
||
from authlib.oauth2.rfc7523 import JWTBearerTokenValidator | ||
from authlib.jose.rfc7517.jwk import JsonWebKey | ||
|
||
|
||
class Auth0JWTBearerTokenValidator(JWTBearerTokenValidator): | ||
def __init__(self, domain, audience): | ||
issuer = f"https://{domain}/" | ||
jsonurl = urlopen(f"{issuer}.well-known/jwks.json") | ||
public_key = JsonWebKey.import_key_set(json.loads(jsonurl.read())) | ||
super(Auth0JWTBearerTokenValidator, self).__init__(public_key) | ||
self.claims_options = { | ||
"exp": {"essential": True}, | ||
"aud": {"essential": True, "value": audience}, | ||
"iss": {"essential": True, "value": issuer}, | ||
} |
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