Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G3-348: Switching to thejacksonlaboratory Auth0 tenant. #90

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/k8s/base/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: ConfigMap
metadata:
name: geneweaver-config
data:
AUTH_CLIENT_ID: "T7bj6wlmtVcAN2O6kzDRwPVFyIj4UQNs"
AUTH_CLIENT_ID: "aE6dpT04mGlvPeUXl4RYGSnCjvHEuawd"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: ConfigMap
metadata:
name: geneweaver-config
data:
AUTH_CLIENT_ID: "oVm9omUtLBpVyL7YfJA8gp3hHaHwyVt8"
AUTH_CLIENT_ID: "C0PrH88Pmjmba9ObVKaIRUITQeiA1Q4D"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kind: ConfigMap
metadata:
name: geneweaver-config
data:
AUTH_CLIENT_ID: "oVm9omUtLBpVyL7YfJA8gp3hHaHwyVt8"
AUTH_CLIENT_ID: "C0PrH88Pmjmba9ObVKaIRUITQeiA1Q4D"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "geneweaver-api"
version = "0.8.0a3"
version = "0.8.0a4"
description = "The Geneweaver API"
authors = [
"Alexander Berger <alexander.berger@jax.org>",
Expand Down
5 changes: 4 additions & 1 deletion src/geneweaver/api/controller/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
redoc_url=f"{settings.API_PREFIX}/redoc",
openapi_url=f"{settings.API_PREFIX}/openapi.json",
swagger_ui_oauth2_redirect_url=f"{settings.API_PREFIX}/docs/oauth2-redirect",
swagger_ui_init_oauth={"clientId": settings.AUTH_CLIENT_ID},
swagger_ui_init_oauth={
"clientId": settings.AUTH_CLIENT_ID,
"scopes": list(settings.AUTH_SCOPES.keys()),
},
lifespan=deps.lifespan,
)

Expand Down
8 changes: 4 additions & 4 deletions src/geneweaver/api/core/config_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def assemble_db_settings(self) -> Self:
)
return self

AUTH_DOMAIN: str = "geneweaver.auth0.com"
AUTH_AUDIENCE: str = "https://api.geneweaver.org"
AUTH_DOMAIN: str = "thejacksonlaboratory.auth0.com"
AUTH_AUDIENCE: str = "https://cube.jax.org"
AUTH_ALGORITHMS: List[str] = ["RS256"]
AUTH_EMAIL_NAMESPACE: str = AUTH_AUDIENCE
AUTH_EMAIL_CLAIM: str = "email"
AUTH_SCOPES: dict = {
"openid profile email": "read",
}
JWT_PERMISSION_PREFIX: str = "approle"
AUTH_CLIENT_ID: str = "T7bj6wlmtVcAN2O6kzDRwPVFyIj4UQNs"
AUTH_CLIENT_ID: str = "aE6dpT04mGlvPeUXl4RYGSnCjvHEuawd"

model_config = SettingsConfigDict(
env_file=".env",
Expand Down
4 changes: 3 additions & 1 deletion src/geneweaver/api/core/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
auto_error: bool = True,
scope_auto_error: bool = True,
email_auto_error: bool = False,
email_claim: str = "email",
auth0user_model: Type[UserInternal] = UserInternal,
) -> None:
"""Initialize the Auth0 class."""
Expand All @@ -80,6 +81,7 @@ def __init__(
self.auto_error = auto_error
self.scope_auto_error = scope_auto_error
self.email_auto_error = email_auto_error
self.email_claim = email_claim

self.auth0_user_model = auth0user_model

Expand Down Expand Up @@ -277,7 +279,7 @@ def _add_auth_info(self, token: str, payload: dict) -> None:
payload["auth_header"] = {"Authorization": f"Bearer {token}"}

def _process_email(self, payload: dict) -> None:
payload["email"] = payload.pop(f"{self.audience}/claims/email")
payload["email"] = payload.pop(f"{self.audience}/{self.email_claim}")

if payload["email"] is not None:
payload["email"] = payload["email"].lower()
1 change: 1 addition & 0 deletions src/geneweaver/api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
domain=settings.AUTH_DOMAIN,
api_audience=settings.AUTH_AUDIENCE,
scopes=settings.AUTH_SCOPES,
email_claim=settings.AUTH_EMAIL_CLAIM,
auto_error=False,
)

Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_test_token(mock_requests, claims=None):
# claims
if claims is None:
to_encode = {
f"{test_audience}/claims/email": test_email,
f"{test_audience}/email": test_email,
"iss": f"https://{test_domain}/",
"aud": test_audience,
"name": test_name,
Expand Down Expand Up @@ -247,7 +247,7 @@ async def test_invalid_claim(
mock_jwt_unverified_header.return_value = private_key

to_encode = {
f"{test_audience}/claims/email": test_email,
f"{test_audience}/email": test_email,
"name": test_name,
"scope": "openid profile email",
}
Expand Down Expand Up @@ -277,7 +277,7 @@ async def test_missing_claim_email_error_claim(
mock_jwt_unverified_header.return_value = private_key

to_encode = {
f"{test_audience}/claims/email": None,
f"{test_audience}/email": None,
"iss": f"https://{test_domain}/",
"aud": test_audience,
"name": test_name,
Expand Down
Loading