Fix login redirect
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
2aa75d9e4b
commit
fb4470fcde
@ -20,8 +20,6 @@ def login_required(_f=None, *, groups=[]):
|
|||||||
print(groups)
|
print(groups)
|
||||||
user = read_user()
|
user = read_user()
|
||||||
if not user:
|
if not user:
|
||||||
print("doing login redirect")
|
|
||||||
session["original_url"] = request.full_path
|
|
||||||
return do_login()
|
return do_login()
|
||||||
if groups and not any(group in groups for group in user["groups"]):
|
if groups and not any(group in groups for group in user["groups"]):
|
||||||
return "not allowed", 401
|
return "not allowed", 401
|
||||||
@ -34,6 +32,10 @@ def login_required(_f=None, *, groups=[]):
|
|||||||
return login_required_inner(_f)
|
return login_required_inner(_f)
|
||||||
|
|
||||||
def do_login():
|
def do_login():
|
||||||
|
print("doing login redirect")
|
||||||
|
if request and request.full_path:
|
||||||
|
print("storing url: " + request.full_path)
|
||||||
|
session["original_url"] = request.full_path
|
||||||
url = add_url_params(metadata["authorization_endpoint"], {
|
url = add_url_params(metadata["authorization_endpoint"], {
|
||||||
"client_id": os.getenv("OIDC_CLIENT_ID"),
|
"client_id": os.getenv("OIDC_CLIENT_ID"),
|
||||||
"redirect_uri": url_for("oidc.login_callback", _external=True, _scheme='https'),
|
"redirect_uri": url_for("oidc.login_callback", _external=True, _scheme='https'),
|
||||||
@ -64,6 +66,7 @@ def login_callback():
|
|||||||
print("authenticated")
|
print("authenticated")
|
||||||
session["id_token"] = r["id_token"]
|
session["id_token"] = r["id_token"]
|
||||||
session["access_token"] = r["access_token"]
|
session["access_token"] = r["access_token"]
|
||||||
|
print("stored url was: " + session.get("original_url"))
|
||||||
return redirect(session.pop("original_url", "/"))
|
return redirect(session.pop("original_url", "/"))
|
||||||
|
|
||||||
@page_oidc.route("/logout")
|
@page_oidc.route("/logout")
|
||||||
|
Loading…
Reference in New Issue
Block a user