11import json
2- import os
32import sys
43import traceback
54from typing import Union
65from urllib .parse import urlparse
76
7+ import werkzeug
88from cryptojwt import as_unicode
99from flask import Blueprint
10- from flask import Response
1110from flask import current_app
1211from flask import redirect
1312from flask import render_template
1413from flask import request
14+ from flask import Response
1515from flask .helpers import make_response
16- from flask . helpers import send_from_directory
16+
1717from idpyoidc .message .oauth2 import ResponseMessage
1818from idpyoidc .message .oidc import AccessTokenRequest
1919from idpyoidc .message .oidc import AuthorizationRequest
20- import werkzeug
21-
22- from idpyoidc .server .exception import FailedAuthentication
2320from idpyoidc .server .exception import ClientAuthenticationError
21+ from idpyoidc .server .exception import FailedAuthentication
2422from idpyoidc .server .oidc .token import Token
2523
2624# logger = logging.getLogger(__name__)
2927
3028
3129def _add_cookie (resp : Response , cookie_spec : Union [dict , list ]):
32- kwargs = {k :v
33- for k ,v in cookie_spec .items ()
30+ kwargs = {k : v
31+ for k , v in cookie_spec .items ()
3432 if k not in ('name' ,)}
3533 kwargs ["path" ] = "/"
3634 kwargs ["samesite" ] = "Lax"
@@ -44,15 +42,22 @@ def add_cookie(resp: Response, cookie_spec: Union[dict, list]):
4442 elif isinstance (cookie_spec , dict ):
4543 _add_cookie (resp , cookie_spec )
4644
47- @oidc_op_views .route ('/static/<path:path>' )
48- def send_js (path ):
49- return send_from_directory ('static' , path )
5045
46+ # @oidc_op_views.route('/static/<path:path>')
47+ # def send_js(path):
48+ # return send_from_directory('static', path)
49+ #
50+ #
51+ # @oidc_op_views.route('/keys/<jwks>')
52+ # def keys(jwks):
53+ # fname = os.path.join('static', jwks)
54+ # return open(fname).read()
55+ #
5156
52- @oidc_op_views .route ('/keys/< jwks> ' )
53- def keys ( jwks ):
54- fname = os . path . join ( 'static' , jwks )
55- return open ( fname ). read ()
57+ @oidc_op_views .route ('/jwks' )
58+ def jwks ( ):
59+ _context = current_app . server . get_context ( )
60+ return _context . keyjar . export_jwks ()
5661
5762
5863@oidc_op_views .route ('/' )
@@ -188,11 +193,13 @@ def token():
188193 return service_endpoint (
189194 current_app .server .get_endpoint ('token' ))
190195
196+
191197@oidc_op_views .route ('/introspection' , methods = ['POST' ])
192198def introspection_endpoint ():
193199 return service_endpoint (
194200 current_app .server .get_endpoint ('introspection' ))
195201
202+
196203@oidc_op_views .route ('/userinfo' , methods = ['GET' , 'POST' ])
197204def userinfo ():
198205 return service_endpoint (
0 commit comments