Skip to content

Commit

Permalink
Add trust_anchor_id to authz response.
Browse files Browse the repository at this point in the history
Make sure the right superior is used.
  • Loading branch information
rohe committed Mar 13, 2024
1 parent a526f2f commit 5abe29e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/fedservice/appclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ def get_client_id(self):
return self.entity_id

def get_metadata(self, *args):
_fed_registration = self.get_service('registration')
_registration = Registration(upstream_get=_fed_registration.upstream_get,
conf=_fed_registration.conf)
request = _registration.construct_request()
return {self.name: request.to_dict()}
metadata = self.context.claims.get_use()
return {self.name: metadata}

def do_request(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/fedservice/appserver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
_token_endp.allow_refresh = allow_refresh_token(self.context)

self.context.claims_interface = init_service(
config["claims_interface"], self.upstream_get
config["claims_interface"], self.unit_get
)

_per_conf = config.get("persistence", None)
Expand Down
8 changes: 6 additions & 2 deletions src/fedservice/appserver/oauth2/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List
from typing import Optional

from fedservice.entity.utils import get_federation_entity
from idpyoidc.message import oauth2
from idpyoidc.message.oauth2 import OauthClientMetadata
from idpyoidc.node import topmost_unit
Expand Down Expand Up @@ -121,6 +122,9 @@ def client_authentication(self, request, auth=None, **kwargs):
return authorization.Authorization.client_authentication(
self, request, auth, **kwargs)

def extra_response_args(self, aresp):
aresp['trust_anchor_id'] = self.upstream_get("context").federation_entity.trust_chain_anchor
def extra_response_args(self, aresp, **kwargs):
_cid = kwargs.get("client_id")
if _cid:
_fe = get_federation_entity(self)
aresp['trust_anchor_id'] = _fe.get_trust_chain(_cid).anchor
return aresp
8 changes: 6 additions & 2 deletions src/fedservice/appserver/oidc/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List
from typing import Optional

from fedservice.entity.utils import get_federation_entity
from idpyoidc.message import oidc
from idpyoidc.message.oidc import RegistrationRequest
from idpyoidc.node import topmost_unit
Expand Down Expand Up @@ -121,6 +122,9 @@ def client_authentication(self, request, auth=None, **kwargs):
return authorization.Authorization.client_authentication(
self, request, auth, **kwargs)

def extra_response_args(self, aresp):
aresp['trust_anchor_id'] = self.upstream_get("context").federation_entity.trust_chain_anchor
def extra_response_args(self, aresp, **kwargs):
_cid = kwargs.get("client_id")
if _cid:
_fe = get_federation_entity(self)
aresp['trust_anchor_id'] = _fe.get_trust_chain(_cid).anchor
return aresp
3 changes: 3 additions & 0 deletions src/fedservice/entity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def get_trust_chain(self, entity_id):
else:
return None

def store_trust_chains(self, entity_id, chains):
self.trust_chain[entity_id] = chains

def get_verified_metadata(self, entity_id: str, *args):
_trust_chains = self.trust_chain.get(entity_id)
if _trust_chains is None:
Expand Down

0 comments on commit 5abe29e

Please sign in to comment.