Skip to content

Commit

Permalink
Add support for extra_claims
Browse files Browse the repository at this point in the history
  • Loading branch information
tpazderka committed Dec 1, 2017
1 parent 81e5791 commit 2094302
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The format is based on the [KeepAChangeLog] project.

## 0.13.0 [Unreleased]

### Added
- [] Ability to specify additional supported claims for oic.Provider

### Fixed
- [#430] Audience of a client assertion is endpoint dependent.
- [#427] Made matching for response_types order independent for authorization requests
Expand Down
7 changes: 6 additions & 1 deletion src/oic/oic/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def __init__(self, name, sdb, cdb, authn_broker, userinfo, authz,
client_authn, symkey=None, urlmap=None, ca_certs="", keyjar=None,
hostname="", template_lookup=None, template=None,
verify_ssl=True, capabilities=None, schema=OpenIDSchema,
jwks_uri='', jwks_name='', baseurl=None, client_cert=None):
jwks_uri='', jwks_name='', baseurl=None, client_cert=None,
extra_claims=None):

AProvider.__init__(self, name, sdb, cdb, authn_broker, authz,
client_authn, symkey, urlmap, ca_bundle=ca_certs,
Expand Down Expand Up @@ -270,6 +271,8 @@ def __init__(self, name, sdb, cdb, authn_broker, userinfo, authz,
self.preferred_id_type = "public"
self.hostname = hostname or socket.gethostname()

self.extra_claims = extra_claims

for endp in self.endp:
if endp.etype == 'registration':
endpoint = urljoin(self.baseurl, endp.url)
Expand Down Expand Up @@ -1692,6 +1695,8 @@ def provider_features(self, pcr_class=ProviderConfigurationResponse):
_claims = []
for _cl in SCOPE2CLAIMS.values():
_claims.extend(_cl)
if self.extra_claims is not None:
_claims.extend(self.extra_claims)
_provider_info["claims_supported"] = list(set(_claims))

_scopes = list(SCOPE2CLAIMS.keys())
Expand Down
6 changes: 6 additions & 0 deletions tests/test_oic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def test_authorization_endpoint(self):
assert parsed["state"][0] == "id-6da9ca0cc23959f5f33e8becd9b08cae"
assert "code" in parsed

def test_provider_features_extra_claims(self):
self.provider.extra_claims = ['claim_1', 'claim_2']
features = self.provider.provider_features()
assert 'claim_1' in features['claims_supported']
assert 'claim_2' in features['claims_supported']

def test_authorization_endpoint_request(self):
bib = {"scope": ["openid"],
"state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
Expand Down

0 comments on commit 2094302

Please sign in to comment.