Skip to content

Commit 0711a00

Browse files
committed
RPHandler uses StandAloneClient.
1 parent aca1857 commit 0711a00

File tree

12 files changed

+250
-630
lines changed

12 files changed

+250
-630
lines changed

src/idpyoidc/client/defaults.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
"response_types": [
3232
"code",
3333
"id_token",
34-
"id_token token",
3534
"code id_token",
36-
"code id_token token",
37-
"code token",
3835
],
3936
"token_endpoint_auth_method": "client_secret_basic",
4037
"scopes_supported": ["openid"],
@@ -48,6 +45,7 @@
4845
# Using PKCE is default
4946
DEFAULT_CLIENT_CONFIGS = {
5047
"": {
48+
"client_type": "oidc",
5149
"preference": DEFAULT_CLIENT_PREFERENCES,
5250
"add_ons": {
5351
"pkce": {

src/idpyoidc/client/oauth2/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ def __init__(
6868
:return: Client instance
6969
"""
7070

71-
if not client_type:
72-
client_type = self.client_type
73-
else:
71+
if client_type:
7472
self.client_type = client_type
73+
elif config and 'client_type' in config:
74+
client_type = self.client_type = config["client_type"]
75+
else:
76+
client_type = self.client_type
7577

7678
if verify_ssl is False:
7779
# just ignore verify_ssl until it goes away

src/idpyoidc/client/oauth2/stand_alone_client.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from idpyoidc.exception import MessageException
1717
from idpyoidc.exception import MissingRequiredAttribute
1818
from idpyoidc.exception import NotForMe
19+
from idpyoidc.message import Message
1920
from idpyoidc.message.oauth2 import is_error_message
2021
from idpyoidc.message.oauth2 import ResponseMessage
2122
from idpyoidc.message.oidc import AuthorizationRequest
@@ -32,7 +33,7 @@
3233

3334
class StandAloneClient(Client):
3435

35-
def get_session_information(self, key, client=None):
36+
def get_session_information(self,key):
3637
"""
3738
This is the second of the methods users of this class should know about.
3839
It will return the complete session information as an
@@ -42,7 +43,7 @@ def get_session_information(self, key, client=None):
4243
:return: A State instance
4344
"""
4445

45-
return client.get_context().cstate.get(key)
46+
return self.get_context().cstate.get(key)
4647

4748
def do_provider_info(
4849
self,
@@ -59,7 +60,7 @@ def do_provider_info(
5960

6061
_context = self.get_context()
6162
_pi = _context.get("provider_info")
62-
if _pi is None:
63+
if _pi is None or _pi == {}:
6364
dynamic_provider_info_discovery(self, behaviour_args=behaviour_args)
6465
_pi = _context.provider_info
6566
elif len(_pi) == 1 and 'issuer' in _pi:
@@ -96,7 +97,11 @@ def do_provider_info(
9697
raise ValueError("Unknown provider JWKS type: {}".format(typ))
9798

9899
_context.map_supported_to_preferred(info=_pi)
99-
return _context.provider_info['issuer']
100+
101+
try:
102+
return _context.provider_info['issuer']
103+
except:
104+
return _context.issuer
100105

101106
def do_client_registration(
102107
self,
@@ -338,7 +343,7 @@ def get_user_info(self, state, access_token="", **kwargs):
338343
return resp
339344

340345
@staticmethod
341-
def userinfo_in_id_token(id_token, user_info_claims: Optional[List] = None):
346+
def userinfo_in_id_token(id_token: Message, user_info_claims: Optional[List] = None) -> dict:
342347
"""
343348
Given a verified ID token return all the claims that may be user information.
344349
@@ -359,7 +364,6 @@ def finalize_auth(
359364
Given the response returned to the redirect_uri, parse and verify it.
360365
361366
:param behaviour_args: For finetuning behaviour
362-
:param issuer: An Issuer ID
363367
:param response: The authorization response as a dictionary
364368
:return: An :py:class:`idpyoidc.message.oidc.AuthorizationResponse` or
365369
:py:class:`idpyoidc.message.oauth2.AuthorizationResponse` instance.
@@ -391,7 +395,11 @@ def finalize_auth(
391395
except KeyError:
392396
raise KeyError("Unknown state value")
393397

394-
issuer = _context.provider_info['issuer']
398+
try:
399+
issuer = _context.provider_info['issuer']
400+
except KeyError:
401+
issuer = _context.issuer
402+
395403
if _iss != issuer:
396404
logger.error("Issuer problem: {} != {}".format(_iss, issuer))
397405
# got it from the wrong bloke
@@ -550,7 +558,7 @@ def finalize(self, response, behaviour_args: Optional[dict] = None):
550558
"token": token["access_token"],
551559
"id_token": _id_token,
552560
"session_state": authorization_response.get("session_state", ""),
553-
"issuer": _context.provider_info['issuer']
561+
"issuer": _context.issuer
554562
}
555563

556564
def has_active_authentication(self, state):

0 commit comments

Comments
 (0)