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

Store public Keycloak cert in vault - part 2 #2786

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
24 changes: 1 addition & 23 deletions src/ol_superset/pythonpath/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json
Ardiea marked this conversation as resolved.
Show resolved Hide resolved
import logging
import os
import urllib.request
from ssl import CERT_OPTIONAL
from typing import Optional

Expand Down Expand Up @@ -76,27 +74,7 @@
# Required config to get Keycloak token for Superset API use
# ----------------------------------------------------------
JWT_ALGORITHM = "RS256"
# URL to the public key endpoint
public_key_url = f"{oidc_creds['url']}/"


def fetch_keycloak_rs256_public_cert():
with urllib.request.urlopen(public_key_url) as response: # noqa: S310
public_key_url_response = json.load(response)
public_key = public_key_url_response["public_key"]
if public_key:
pem_lines = [
"-----BEGIN PUBLIC KEY-----",
public_key,
"-----END PUBLIC KEY-----",
]
cert_pem = "\n".join(pem_lines)
else:
cert_pem = "No cert found"
return cert_pem


JWT_PUBLIC_KEY = fetch_keycloak_rs256_public_cert()
JWT_PUBLIC_KEY = oidc_creds["realm_public_key"]

# Testing out Keycloak role mapping to Superset
# https://superset.apache.org/docs/installation/configuring-superset#mapping-ldap-or-oauth-groups-to-superset-roles
Expand Down