diff --git a/canaille/ldap_backend/schemas/oauth2-openldap.ldif b/canaille/ldap_backend/schemas/oauth2-openldap.ldif index bcfb65d5..061f95b2 100644 --- a/canaille/ldap_backend/schemas/oauth2-openldap.ldif +++ b/canaille/ldap_backend/schemas/oauth2-openldap.ldif @@ -135,7 +135,6 @@ olcAttributeTypes: ( 1.3.6.1.4.1.56207.1.1.16 NAME 'oauthClientContact' ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE USAGE userApplications X-ORIGIN 'OAuth 2.0' ) olcAttributeTypes: ( 1.3.6.1.4.1.56207.1.1.17 NAME 'oauthClientURI' diff --git a/canaille/ldap_backend/schemas/oauth2-openldap.schema b/canaille/ldap_backend/schemas/oauth2-openldap.schema index 46614fbf..6d8ef18f 100644 --- a/canaille/ldap_backend/schemas/oauth2-openldap.schema +++ b/canaille/ldap_backend/schemas/oauth2-openldap.schema @@ -132,7 +132,6 @@ attributetype ( 1.3.6.1.4.1.56207.1.1.16 NAME 'oauthClientContact' ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 - SINGLE-VALUE USAGE userApplications X-ORIGIN 'OAuth 2.0' ) attributetype ( 1.3.6.1.4.1.56207.1.1.17 NAME 'oauthClientURI' diff --git a/canaille/oidc/clients.py b/canaille/oidc/clients.py index 2b48b314..b06e1931 100644 --- a/canaille/oidc/clients.py +++ b/canaille/oidc/clients.py @@ -28,21 +28,21 @@ def index(user): def client_audiences(): - return [(client.dn, client.name) for client in Client.all()] + return [(client.dn, client.client_name) for client in Client.all()] class ClientAdd(FlaskForm): - name = wtforms.StringField( + client_name = wtforms.StringField( _("Name"), validators=[wtforms.validators.DataRequired()], render_kw={"placeholder": "Client Name"}, ) - contact = wtforms.EmailField( + contacts = wtforms.EmailField( _("Contact"), validators=[wtforms.validators.Optional()], render_kw={"placeholder": "admin@mydomain.tld"}, ) - uri = wtforms.URLField( + client_uri = wtforms.URLField( _("URI"), validators=[wtforms.validators.DataRequired()], render_kw={"placeholder": "https://mydomain.tld"}, @@ -57,7 +57,7 @@ class ClientAdd(FlaskForm): validators=[wtforms.validators.Optional()], render_kw={"placeholder": "https://mydomain.tld/you-have-been-disconnected"}, ) - grant_type = wtforms.SelectMultipleField( + grant_types = wtforms.SelectMultipleField( _("Grant types"), validators=[wtforms.validators.DataRequired()], choices=[ @@ -75,7 +75,7 @@ class ClientAdd(FlaskForm): default="openid profile email", render_kw={"placeholder": "openid profile"}, ) - response_type = wtforms.SelectMultipleField( + response_types = wtforms.SelectMultipleField( _("Response types"), validators=[wtforms.validators.DataRequired()], choices=[("code", "code"), ("token", "token"), ("id_token", "id_token")], @@ -127,7 +127,7 @@ class ClientAdd(FlaskForm): validators=[wtforms.validators.Optional()], render_kw={"placeholder": ""}, ) - jwk_uri = wtforms.URLField( + jwks_uri = wtforms.URLField( _("JKW URI"), validators=[wtforms.validators.Optional()], render_kw={"placeholder": ""}, @@ -162,14 +162,14 @@ def add(user): client_id_issued_at = datetime.datetime.now() client = Client( client_id=client_id, - issue_date=client_id_issued_at, - name=form["name"].data, - contact=form["contact"].data, - uri=form["uri"].data, - grant_type=form["grant_type"].data, + client_id_issued_at=client_id_issued_at, + client_name=form["client_name"].data, + contacts=[form["contacts"].data], + client_uri=form["client_uri"].data, + grant_types=form["grant_types"].data, redirect_uris=[form["redirect_uris"].data], post_logout_redirect_uris=[form["post_logout_redirect_uris"].data], - response_type=form["response_type"].data, + response_types=form["response_types"].data, scope=form["scope"].data.split(" "), token_endpoint_auth_method=form["token_endpoint_auth_method"].data, logo_uri=form["logo_uri"].data, @@ -178,9 +178,9 @@ def add(user): software_id=form["software_id"].data, software_version=form["software_version"].data, jwk=form["jwk"].data, - jwk_uri=form["jwk_uri"].data, + jwks_uri=form["jwks_uri"].data, preconsent=form["preconsent"].data, - secret="" + client_secret="" if form["token_endpoint_auth_method"].data == "none" else gen_salt(48), ) @@ -236,13 +236,13 @@ def client_edit(client_id): else: client.update( - name=form["name"].data, - contact=form["contact"].data, - uri=form["uri"].data, - grant_type=form["grant_type"].data, + client_name=form["client_name"].data, + contacts=[form["contacts"].data], + client_uri=form["client_uri"].data, + grant_types=form["grant_types"].data, redirect_uris=[form["redirect_uris"].data], post_logout_redirect_uris=[form["post_logout_redirect_uris"].data], - response_type=form["response_type"].data, + response_types=form["response_types"].data, scope=form["scope"].data.split(" "), token_endpoint_auth_method=form["token_endpoint_auth_method"].data, logo_uri=form["logo_uri"].data, @@ -251,7 +251,7 @@ def client_edit(client_id): software_id=form["software_id"].data, software_version=form["software_version"].data, jwk=form["jwk"].data, - jwk_uri=form["jwk_uri"].data, + jwks_uri=form["jwks_uri"].data, audience=form["audience"].data, preconsent=form["preconsent"].data, ) diff --git a/canaille/oidc/models.py b/canaille/oidc/models.py index 6e9f6348..c4b18acb 100644 --- a/canaille/oidc/models.py +++ b/canaille/oidc/models.py @@ -15,21 +15,21 @@ class Client(LDAPObject, ClientMixin): attribute_table = { "description": "description", "client_id": "oauthClientID", - "name": "oauthClientName", - "contact": "oauthClientContact", - "uri": "oauthClientURI", + "client_name": "oauthClientName", + "contacts": "oauthClientContact", + "client_uri": "oauthClientURI", "redirect_uris": "oauthRedirectURIs", "post_logout_redirect_uris": "oauthPostLogoutRedirectURI", "logo_uri": "oauthLogoURI", - "issue_date": "oauthIssueDate", - "secret": "oauthClientSecret", - "secret_expires_date": "oauthClientSecretExpDate", - "grant_type": "oauthGrantType", - "response_type": "oauthResponseType", + "client_id_issued_at": "oauthIssueDate", + "client_secret": "oauthClientSecret", + "client_secret_expires_date": "oauthClientSecretExpDate", + "grant_types": "oauthGrantType", + "response_types": "oauthResponseType", "scope": "oauthScope", "tos_uri": "oauthTermsOfServiceURI", "policy_uri": "oauthPolicyURI", - "jwk_uri": "oauthJWKURI", + "jwks_uri": "oauthJWKURI", "jwk": "oauthJWK", "token_endpoint_auth_method": "oauthTokenEndpointAuthMethod", "software_id": "oauthSoftwareID", @@ -50,10 +50,10 @@ class Client(LDAPObject, ClientMixin): return redirect_uri in self.redirect_uris def has_client_secret(self): - return bool(self.secret) + return bool(self.client_secret) def check_client_secret(self, client_secret): - return client_secret == self.secret + return client_secret == self.client_secret def check_endpoint_auth_method(self, method, endpoint): if endpoint == "token": @@ -61,10 +61,10 @@ class Client(LDAPObject, ClientMixin): return True def check_response_type(self, response_type): - return all(r in self.response_type for r in response_type.split(" ")) + return all(r in self.response_types for r in response_type.split(" ")) def check_grant_type(self, grant_type): - return grant_type in self.grant_type + return grant_type in self.grant_types @property def client_info(self): diff --git a/canaille/templates/oidc/admin/client_edit.html b/canaille/templates/oidc/admin/client_edit.html index 4c37d8d0..2a1a72bb 100644 --- a/canaille/templates/oidc/admin/client_edit.html +++ b/canaille/templates/oidc/admin/client_edit.html @@ -49,7 +49,7 @@
{{ _("You are currently logged in as %(username)s.", username=user.name) }} {% if client %} - {{ _("The application %(client_name)s want to disconnect your account.", client_name=client.name) }} + {{ _("The application %(client_name)s want to disconnect your account.", client_name=client.client_name) }} {% endif %}