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

Add auth_level functionality #84

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions server/weblogin_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Session(app)

oidc_enabled = config['oidc']['enabled']
min_auth_level = config['oidc']['min_auth_level']

if oidc_enabled:
client_metadata = ClientMetadata(
Expand Down Expand Up @@ -245,6 +246,15 @@ def __login(session_id):
message += f"{attribute_id} successfully authenticated<br>\n"
message += f"Verification code: {code}<br><br>\n"
message += "<i>This window may be closed</i>\n"
if min_auth_level != 0:
# Get access_token to introspect on for auth_level validation
access_token = authzn.valid_access_token()
introspection = authzn.clients['pam-weblogin']._token_introspection_request(access_token)
if 'auth_level' in introspection:
if introspection['auth_level'] < min_auth_level:
message = f"min_auth_level {introspection['auth_level']} less than {min_auth_level}. You need MFA"
else:
logging.debug('auth_level missing from introspect request')
else:
message = f"user_id {user_id} not found\n"
else:
Expand Down
1 change: 1 addition & 0 deletions server/weblogin_daemon.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ oidc:
client_id: '<client>'
client_secret: '<secret>'
redirect_uri: 'https://<server>>/redirect_uri
min_auth_level: 0
Loading