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

Rename env vars to ORCID_NMDC_CLIENT_{ID,SECRET} #446

Merged
merged 1 commit into from
Jan 24, 2024
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
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ NEON_API_TOKEN=y
NEON_API_BASE_URL=https://data.neonscience.org/api/v0

NERSC_USERNAME=replaceme
ORCID_CLIENT_ID=replaceme
ORCID_CLIENT_SECRET=replaceme
ORCID_NMDC_CLIENT_ID=replaceme
ORCID_NMDC_CLIENT_SECRET=replaceme
4 changes: 2 additions & 2 deletions nmdc_runtime/api/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

SECRET_KEY = os.getenv("JWT_SECRET_KEY")
ALGORITHM = "HS256"
ORCID_CLIENT_ID = os.getenv("ORCID_CLIENT_ID")
ORCID_CLIENT_SECRET = os.getenv("ORCID_CLIENT_SECRET")
ORCID_NMDC_CLIENT_ID = os.getenv("ORCID_NMDC_CLIENT_ID")
ORCID_NMDC_CLIENT_SECRET = os.getenv("ORCID_NMDC_CLIENT_SECRET")

# https://orcid.org/.well-known/openid-configuration
# XXX do we want to live-load this?
Expand Down
6 changes: 3 additions & 3 deletions nmdc_runtime/api/endpoints/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
Token,
ACCESS_TOKEN_EXPIRES,
create_access_token,
ORCID_CLIENT_ID,
ORCID_NMDC_CLIENT_ID,
ORCID_JWK,
ORCID_JWS_VERITY_ALGORITHM,
credentials_exception,
ORCID_CLIENT_SECRET,
ORCID_NMDC_CLIENT_SECRET,
)
from nmdc_runtime.api.core.auth import get_password_hash
from nmdc_runtime.api.core.util import generate_secret
Expand All @@ -40,7 +40,7 @@ async def receive_orcid_code(request: Request, code: str, state: str | None = No
rv = requests.post(
"https://orcid.org/oauth/token",
data=(
f"client_id={ORCID_CLIENT_ID}&client_secret={ORCID_CLIENT_SECRET}&"
f"client_id={ORCID_NMDC_CLIENT_ID}&client_secret={ORCID_NMDC_CLIENT_SECRET}&"
f"grant_type=authorization_code&code={code}&redirect_uri={BASE_URL_EXTERNAL}/orcid_code"
),
headers={
Expand Down
4 changes: 2 additions & 2 deletions nmdc_runtime/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ensure_unique_id_indexes,
REPO_ROOT_DIR,
)
from nmdc_runtime.api.core.auth import get_password_hash, ORCID_CLIENT_ID
from nmdc_runtime.api.core.auth import get_password_hash, ORCID_NMDC_CLIENT_ID
from nmdc_runtime.api.db.mongo import (
get_mongo_db,
)
Expand Down Expand Up @@ -366,7 +366,7 @@ async def get_versions():
f'nmdc-schema={version("nmdc_schema")}\n\n'
"<a href='https://microbiomedata.github.io/nmdc-runtime/'>Documentation</a>\n\n"
'<img src="/static/ORCIDiD_icon128x128.png" height="18" width="18"/> '
f'<a href="https://orcid.org/oauth/authorize?client_id={ORCID_CLIENT_ID}'
f'<a href="https://orcid.org/oauth/authorize?client_id={ORCID_NMDC_CLIENT_ID}'
"&response_type=code&scope=openid&"
f'redirect_uri={BASE_URL_EXTERNAL}/orcid_code">Login with ORCiD</a>'
" (note: this link is static; if you are logged in, you will see a 'locked' lock icon"
Expand Down