Skip to content

Commit

Permalink
More dynamic key management
Browse files Browse the repository at this point in the history
  • Loading branch information
rohe committed Jun 12, 2024
1 parent ec31dee commit f3d0bca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
7 changes: 3 additions & 4 deletions example/flask_op/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
}
}
},
"capabilities": {
"preference": {
"subject_types_supported": [
"public",
"pairwise"
Expand Down Expand Up @@ -278,9 +278,8 @@
]
}
],
"public_path": "static/jwks.json",
"read_only": false,
"uri_path": "static/jwks.json"
"uri_path": "jwks"
},
"login_hint2acrs": {
"class": "idpyoidc.server.login_hint.LoginHint2Acrs",
Expand Down Expand Up @@ -350,6 +349,6 @@
"verify_user": false,
"port": 5000,
"domain": "127.0.0.1",
"debug": true
"debug": false
}
}
37 changes: 22 additions & 15 deletions example/flask_op/views.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import json
import os
import sys
import traceback
from typing import Union
from urllib.parse import urlparse

import werkzeug
from cryptojwt import as_unicode
from flask import Blueprint
from flask import Response
from flask import current_app
from flask import redirect
from flask import render_template
from flask import request
from flask import Response
from flask.helpers import make_response
from flask.helpers import send_from_directory

from idpyoidc.message.oauth2 import ResponseMessage
from idpyoidc.message.oidc import AccessTokenRequest
from idpyoidc.message.oidc import AuthorizationRequest
import werkzeug

from idpyoidc.server.exception import FailedAuthentication
from idpyoidc.server.exception import ClientAuthenticationError
from idpyoidc.server.exception import FailedAuthentication
from idpyoidc.server.oidc.token import Token

# logger = logging.getLogger(__name__)
Expand All @@ -29,8 +27,8 @@


def _add_cookie(resp: Response, cookie_spec: Union[dict, list]):
kwargs = {k:v
for k,v in cookie_spec.items()
kwargs = {k: v
for k, v in cookie_spec.items()
if k not in ('name',)}
kwargs["path"] = "/"
kwargs["samesite"] = "Lax"
Expand All @@ -44,15 +42,22 @@ def add_cookie(resp: Response, cookie_spec: Union[dict, list]):
elif isinstance(cookie_spec, dict):
_add_cookie(resp, cookie_spec)

@oidc_op_views.route('/static/<path:path>')
def send_js(path):
return send_from_directory('static', path)

# @oidc_op_views.route('/static/<path:path>')
# def send_js(path):
# return send_from_directory('static', path)
#
#
# @oidc_op_views.route('/keys/<jwks>')
# def keys(jwks):
# fname = os.path.join('static', jwks)
# return open(fname).read()
#

@oidc_op_views.route('/keys/<jwks>')
def keys(jwks):
fname = os.path.join('static', jwks)
return open(fname).read()
@oidc_op_views.route('/jwks')
def jwks():
_context = current_app.server.get_context()
return _context.keyjar.export_jwks()


@oidc_op_views.route('/')
Expand Down Expand Up @@ -188,11 +193,13 @@ def token():
return service_endpoint(
current_app.server.get_endpoint('token'))


@oidc_op_views.route('/introspection', methods=['POST'])
def introspection_endpoint():
return service_endpoint(
current_app.server.get_endpoint('introspection'))


@oidc_op_views.route('/userinfo', methods=['GET', 'POST'])
def userinfo():
return service_endpoint(
Expand Down

0 comments on commit f3d0bca

Please sign in to comment.