|
| 1 | +from typing import Optional |
| 2 | + |
| 3 | +from idpyoidc.client import claims |
| 4 | +from idpyoidc.message.oauth2 import OAuthProtectedResourceRequest |
| 5 | +from idpyoidc.client.claims.transform import array_or_singleton |
| 6 | + |
| 7 | +class Claims(claims.Claims): |
| 8 | + _supports = { |
| 9 | + "resource": None, |
| 10 | + "grant_types_supported": ["authorization_code", "implicit", "refresh_token"], |
| 11 | + "scopes_supported": [], |
| 12 | + "authorization_servers": [], |
| 13 | + "bearer_methods_supported": [], |
| 14 | + "resource_documentation": None, |
| 15 | + "resource_signing_alg_values_supported": [], |
| 16 | + "resource_encryption_alg_values_supported": [], |
| 17 | + "resource_encryption_enc_values_supported": [], |
| 18 | + "client_registration_types": [], |
| 19 | + "organization_name": None, |
| 20 | + "resource_policy_uri": None, |
| 21 | + "resource_tos_uri": None |
| 22 | + } |
| 23 | + |
| 24 | + callback_path = {} |
| 25 | + |
| 26 | + callback_uris = ["redirect_uris"] |
| 27 | + |
| 28 | + def __init__(self, prefer: Optional[dict] = None, callback_path: Optional[dict] = None): |
| 29 | + claims.Claims.__init__(self, prefer=prefer, callback_path=callback_path) |
| 30 | + |
| 31 | + def create_registration_request(self): |
| 32 | + _request = {} |
| 33 | + for key, spec in OAuthProtectedResourceRequest.c_param.items(): |
| 34 | + _pref_key = key |
| 35 | + if _pref_key in self.prefer: |
| 36 | + value = self.prefer[_pref_key] |
| 37 | + elif _pref_key in self.supports(): |
| 38 | + value = self.supports()[_pref_key] |
| 39 | + else: |
| 40 | + continue |
| 41 | + |
| 42 | + if not value: |
| 43 | + continue |
| 44 | + |
| 45 | + _request[key] = array_or_singleton(spec, value) |
| 46 | + return _request |
0 commit comments