Skip to content

Commit 3e10f16

Browse files
committed
fix(auth): add TODO comments for future env vars (reanahub#745)
1 parent fc3657a commit 3e10f16

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

docs/openapi.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,30 @@
1010
"/api/.well-known/openid-configuration": {
1111
"get": {
1212
"description": "Returns the OpenID configuration for the REANA server.",
13+
"operationId": "get_openid_configuration",
14+
"produces": [
15+
"application/json"
16+
],
1317
"responses": {
1418
"200": {
15-
"description": "OpenID configuration"
19+
"description": "OpenID configuration",
20+
"schema": {
21+
"properties": {
22+
"authorization_endpoint": {
23+
"type": "string"
24+
},
25+
"device_authorization_endpoint": {
26+
"type": "string"
27+
},
28+
"reana_client_id": {
29+
"type": "string"
30+
},
31+
"token_endpoint": {
32+
"type": "string"
33+
}
34+
},
35+
"type": "object"
36+
}
1637
},
1738
"404": {
1839
"description": "OpenID configuration not found"

reana_server/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,19 @@ def _get_rate_limit(env_variable: str, default: str) -> str:
486486

487487
# Authentication configuration
488488
# =====================
489+
# TODO The env location will be changed after `reana-server` jwt PR is merged and env variable structure agreed
489490
REANA_AUTH = {
490491
"openid": {
491492
"config_url": os.getenv(
492-
"OPENID_CONFIG_URL",
493+
"REANA_AUTH_OPENID_CONFIG_URL",
493494
"https://auth.cern.ch/auth/realms/cern/.well-known/openid-configuration",
494-
)
495-
}
495+
),
496+
},
497+
"client_id": os.getenv(
498+
"REANA_AUTH_CLIENT_ID",
499+
# TODO Change me to something more reasonable (currently it is just temp client_id)
500+
# Used for CLI authentication to avoid extra configuration on client environments
501+
"f671a136-8e92-45e5-83bd-05af1942e396",
502+
),
496503
}
497504
"""Authentication configuration for REANA."""

reana_server/rest/auth.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,31 @@ def get_openid_configuration():
2525
summary: Get OpenID Configuration
2626
description: >-
2727
Returns the OpenID configuration for the REANA server.
28+
operationId: get_openid_configuration
29+
produces:
30+
- application/json
2831
responses:
29-
'200':
32+
200:
3033
description: >-
3134
OpenID configuration
35+
schema:
36+
type: object
37+
properties:
38+
device_authorization_endpoint:
39+
type: string
40+
authorization_endpoint:
41+
type: string
42+
token_endpoint:
43+
type: string
44+
reana_client_id:
45+
type: string
3246
'404':
3347
description: OpenID configuration not found
3448
'500':
3549
description: Internal server error
3650
"""
3751
try:
52+
# TODO The env location will be changed after `reana-server` jwt PR is merged and env variable structure agreed
3853
url = REANA_AUTH["openid"]["config_url"]
3954

4055
if not url:
@@ -43,6 +58,9 @@ def get_openid_configuration():
4358
if response.status_code == 404:
4459
return jsonify({"message": "OpenID configuration not found"}), 404
4560
response.raise_for_status()
46-
return jsonify(response.json()), 200
61+
openid_config = response.json()
62+
openid_config["reana_client_id"] = REANA_AUTH["client_id"]
63+
64+
return jsonify(openid_config), 200
4765
except requests.RequestException:
4866
return jsonify({"message": "Failed to fetch OpenID configuration"}), 502

0 commit comments

Comments
 (0)