Skip to content

Commit

Permalink
change flask oidc package and adjusted code & config accordingly to f…
Browse files Browse the repository at this point in the history
…ree up package requirments / allow newer versions
  • Loading branch information
lzuba committed Oct 9, 2023
1 parent 9ebf7e4 commit 96d88aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 5 additions & 7 deletions app/starter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/PATH/TO/YOUR/PYTHON3
import functools
import os, logging, Controller, sys, base64, customSessionInterface
from flask_oidc_ex import OpenIDConnect
from flask import Flask, request, jsonify, make_response, send_from_directory, render_template, Response
from flask_oidc import OpenIDConnect
from flask import Flask, request, jsonify, make_response, send_from_directory, render_template, Response, session
import flask_wtf.csrf
from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher
from markupsafe import Markup
Expand All @@ -21,7 +21,6 @@
"OIDC_COOKIE_SECURE": True,
"OIDC_CLIENT_SECRETS": "app/secrets.json",
"OIDC_ID_TOKEN_COOKIE_SECURE": True,
"OIDC_REQUIRE_VERIFIED_EMAIL": True,
"OIDC_CLOCK_SKEW": 3600,
"OVERWRITE_REDIRECT_URI": f"https://mlaps.{companyName}.com/oidc_callback",
"OIDC_RESOURCE_SERVER_VALIDATION_MODE": "online",
Expand All @@ -42,10 +41,9 @@

def get_oidc_user_info() -> dict:
if oidc.user_loggedin:
info = oidc.user_getinfo(["groups", "preferred_username", "email"])
username = info.get("preferred_username")
email = info.get("email")
groups = info.get("groups")
username = session['oidc_auth_profile']["preferred_username"]
email = session['oidc_auth_profile']["email"]
groups = session['oidc_auth_profile']["groups"]
return {"username": username, "email": email, "groups": groups}
else:
return None
Expand Down
10 changes: 5 additions & 5 deletions docker/keycloak/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,16 @@
}, {
"id" : "82e2618a-7b8b-44aa-904b-c8e31990f404",
"clientId" : "mlaps",
"rootUrl" : "https://mlaps.$YOURCOMPANY.com",
"adminUrl" : "https://mlaps.$YOURCOMPANY.com",
"baseUrl" : "https://mlaps.$YOURCOMPANY.com",
"rootUrl" : "https://mlaps.foobar.com",
"adminUrl" : "https://mlaps.foobar.com",
"baseUrl" : "https://mlaps.foobar.com",
"surrogateAuthRequired" : false,
"enabled" : true,
"alwaysDisplayInConsole" : false,
"clientAuthenticatorType" : "client-secret",
"secret" : "7mF1V9zO8wsZIHOicQBAsqsYCaUqJqkC",
"redirectUris" : [ "https://mlaps.$YOURCOMPANY.com/oidc_callback" ],
"webOrigins" : [ "https://mlaps.$YOURCOMPANY.com" ],
"redirectUris" : [ "https://mlaps.foobar.com/authorize" ],
"webOrigins" : [ "https://mlaps.foobar.com" ],
"notBefore" : 0,
"bearerOnly" : false,
"consentRequired" : false,
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask
flask_oidc_ex
itsdangerous==2.0.1
flask_oidc
itsdangerous
hvac
Flask-APScheduler
pyOpenSSL
Expand Down

0 comments on commit 96d88aa

Please sign in to comment.