Skip to content

Commit

Permalink
Remove uppercase logic from oidc_auth
Browse files Browse the repository at this point in the history
Remove automatic conversion of provider names to uppercase from
get_oidc_secondary_providers().

Update the OIDC middleware to convert the secondary provider name to
uppercase before validation.
  • Loading branch information
sbreker committed Sep 26, 2024
1 parent c71e20f commit 9ed10ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/dashboard/src/middleware/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def __init__(self, get_response):
def __call__(self, request):
if not request.user.is_authenticated:
# Capture query parameter value and store it in the session.
provider_name = request.GET.get(settings.OIDC_PROVIDER_QUERY_PARAM_NAME)
provider_name = request.GET.get(
settings.OIDC_PROVIDER_QUERY_PARAM_NAME, ""
).upper()

if provider_name and provider_name in settings.OIDC_PROVIDERS:
request.session["providername"] = provider_name
Expand Down
28 changes: 13 additions & 15 deletions src/dashboard/src/settings/components/oidc_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@


def get_oidc_secondary_providers(oidc_secondary_provider_names):
"""Build secondary OIDC provider details dict. Takes a list of secondary
OIDC providers and gathers details about these providers from env vars.
Output dict contains details for each OIDC connection which can then be
referenced by name.
"""

providers = {}

for provider_name in oidc_secondary_provider_names:
provider_name = provider_name.strip()
client_id = os.environ.get(f"OIDC_RP_CLIENT_ID_{provider_name.upper()}")
client_secret = os.environ.get(f"OIDC_RP_CLIENT_SECRET_{provider_name.upper()}")
client_id = os.environ.get(f"OIDC_RP_CLIENT_ID_{provider_name}")
client_secret = os.environ.get(f"OIDC_RP_CLIENT_SECRET_{provider_name}")
authorization_endpoint = os.environ.get(
f"OIDC_OP_AUTHORIZATION_ENDPOINT_{provider_name.upper()}", ""
)
token_endpoint = os.environ.get(
f"OIDC_OP_TOKEN_ENDPOINT_{provider_name.upper()}", ""
)
user_endpoint = os.environ.get(
f"OIDC_OP_USER_ENDPOINT_{provider_name.upper()}", ""
)
jwks_endpoint = os.environ.get(
f"OIDC_OP_JWKS_ENDPOINT_{provider_name.upper()}", ""
)
logout_endpoint = os.environ.get(
f"OIDC_OP_LOGOUT_ENDPOINT_{provider_name.upper()}", ""
f"OIDC_OP_AUTHORIZATION_ENDPOINT_{provider_name}", ""
)
token_endpoint = os.environ.get(f"OIDC_OP_TOKEN_ENDPOINT_{provider_name}", "")
user_endpoint = os.environ.get(f"OIDC_OP_USER_ENDPOINT_{provider_name}", "")
jwks_endpoint = os.environ.get(f"OIDC_OP_JWKS_ENDPOINT_{provider_name}", "")
logout_endpoint = os.environ.get(f"OIDC_OP_LOGOUT_ENDPOINT_{provider_name}", "")

if client_id and client_secret:
providers[provider_name] = {
Expand Down

0 comments on commit 9ed10ef

Please sign in to comment.