Skip to content

Commit

Permalink
Merge pull request #84 from BlackLotus/main
Browse files Browse the repository at this point in the history
Add auth_level functionality
  • Loading branch information
baszoetekouw committed Jun 5, 2024
2 parents 03a9229 + b50f892 commit 152d2e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit 152d2e2

Please sign in to comment.