Replies: 3 comments 8 replies
-
Back then, Prefect had a bigger misalignment with our setup in terms of the user RBAC structure and secret management. The underlying lib for the workflows was not as polished as it is right now. |
Beta Was this translation helpful? Give feedback.
-
Hey @verhulstm, I can try finding that, but we need to look into the git history from when nebari was called qhub. So that may take some time, until I can have the time to search for it. On the other hand, if you need authentication with keycloak all you need is that your application accepts the OpenID protocol. You can create a In your Flask, example you should be able to see an option to enable authentication within the Flask app In their docs, look for something around openID -- I can try to wrap an example of this when I have some time. |
Beta Was this translation helpful? Give feedback.
-
here's an example I found in the web : import os
from flask import Flask, redirect, url_for, session, render_template_string
from authlib.integrations.flask_client import OAuth
from dotenv import load_dotenv
import requests
load_dotenv()
app = Flask(__name__)
app.secret_key = os.getenv("FLASK_SECRET_KEY")
oauth = OAuth(app)
oauth.register(
name="keycloak",
client_id=os.getenv("KEYCLOAK_CLIENT_ID"),
client_secret=os.getenv("KEYCLOAK_CLIENT_SECRET"),
server_metadata_url=os.getenv("KEYCLOAK_SERVER_METADATA_URL"),
client_kwargs={"scope": "openid profile email"},
)
@app.route("/")
def index():
user = session.get("user")
if user:
return render_template_string('''
<h1>Welcome, {{ user['name'] }}!</h1>
<form action="{{ url_for('logout') }}" method="post">
<button type="submit">Logout</button>
</form>
''', user=user)
else:
return render_template_string('''
<h1>Hello, you are not logged in.</h1>
<form action="{{ url_for('login') }}" method="post">
<button type="submit">Login</button>
</form>
''')
# Login page
@app.route("/login", methods=["POST"])
def login():
redirect_uri = url_for("auth", _external=True)
return oauth.keycloak.authorize_redirect(redirect_uri)
# Auth callback
@app.route("/auth")
def auth():
token = oauth.keycloak.authorize_access_token()
session["user"] = oauth.keycloak.parse_id_token(token)
return redirect("/")
# Logout
@app.route("/logout", methods=["POST"])
def logout():
session.pop("user", None)
logout_url = f"{os.getenv('KEYCLOAK_LOGOUT_URL')}?redirect_uri={url_for('index', _external=True)}"
return redirect(logout_url)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000) you would just need to adapt it to properly use the keycloak's client information. If you are installing your app trough nebari's helm extension mechanism, you can try creating a kuberntes secret and use that to mount into your pod with the clients info |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
for our use case we need Prefect. it is interesting that it was removed
Beta Was this translation helpful? Give feedback.
All reactions