providers/scim: change familyName default (#7904)
* Update providers-scim.yaml Signed-off-by: Antoine <antoine+github@jiveoff.fr> * fix: add formatted to match the givenName & familyName Signed-off-by: Antoine <antoine+github@jiveoff.fr> * fix, update tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Antoine <antoine+github@jiveoff.fr> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Antoine <antoine+github@jiveoff.fr>
This commit is contained in:
parent
1a21af0361
commit
ba174d810b
|
@ -57,7 +57,7 @@ class SCIMUserTests(TestCase):
|
||||||
uid = generate_id()
|
uid = generate_id()
|
||||||
user = User.objects.create(
|
user = User.objects.create(
|
||||||
username=uid,
|
username=uid,
|
||||||
name=uid,
|
name=f"{uid} {uid}",
|
||||||
email=f"{uid}@goauthentik.io",
|
email=f"{uid}@goauthentik.io",
|
||||||
)
|
)
|
||||||
self.assertEqual(mock.call_count, 2)
|
self.assertEqual(mock.call_count, 2)
|
||||||
|
@ -77,11 +77,11 @@ class SCIMUserTests(TestCase):
|
||||||
],
|
],
|
||||||
"externalId": user.uid,
|
"externalId": user.uid,
|
||||||
"name": {
|
"name": {
|
||||||
"familyName": "",
|
"familyName": uid,
|
||||||
"formatted": uid,
|
"formatted": f"{uid} {uid}",
|
||||||
"givenName": uid,
|
"givenName": uid,
|
||||||
},
|
},
|
||||||
"displayName": uid,
|
"displayName": f"{uid} {uid}",
|
||||||
"userName": uid,
|
"userName": uid,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -110,7 +110,7 @@ class SCIMUserTests(TestCase):
|
||||||
uid = generate_id()
|
uid = generate_id()
|
||||||
user = User.objects.create(
|
user = User.objects.create(
|
||||||
username=uid,
|
username=uid,
|
||||||
name=uid,
|
name=f"{uid} {uid}",
|
||||||
email=f"{uid}@goauthentik.io",
|
email=f"{uid}@goauthentik.io",
|
||||||
)
|
)
|
||||||
self.assertEqual(mock.call_count, 2)
|
self.assertEqual(mock.call_count, 2)
|
||||||
|
@ -131,11 +131,11 @@ class SCIMUserTests(TestCase):
|
||||||
"value": f"{uid}@goauthentik.io",
|
"value": f"{uid}@goauthentik.io",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"displayName": uid,
|
"displayName": f"{uid} {uid}",
|
||||||
"externalId": user.uid,
|
"externalId": user.uid,
|
||||||
"name": {
|
"name": {
|
||||||
"familyName": "",
|
"familyName": uid,
|
||||||
"formatted": uid,
|
"formatted": f"{uid} {uid}",
|
||||||
"givenName": uid,
|
"givenName": uid,
|
||||||
},
|
},
|
||||||
"userName": uid,
|
"userName": uid,
|
||||||
|
@ -166,7 +166,7 @@ class SCIMUserTests(TestCase):
|
||||||
uid = generate_id()
|
uid = generate_id()
|
||||||
user = User.objects.create(
|
user = User.objects.create(
|
||||||
username=uid,
|
username=uid,
|
||||||
name=uid,
|
name=f"{uid} {uid}",
|
||||||
email=f"{uid}@goauthentik.io",
|
email=f"{uid}@goauthentik.io",
|
||||||
)
|
)
|
||||||
self.assertEqual(mock.call_count, 2)
|
self.assertEqual(mock.call_count, 2)
|
||||||
|
@ -186,11 +186,11 @@ class SCIMUserTests(TestCase):
|
||||||
],
|
],
|
||||||
"externalId": user.uid,
|
"externalId": user.uid,
|
||||||
"name": {
|
"name": {
|
||||||
"familyName": "",
|
"familyName": uid,
|
||||||
"formatted": uid,
|
"formatted": f"{uid} {uid}",
|
||||||
"givenName": uid,
|
"givenName": uid,
|
||||||
},
|
},
|
||||||
"displayName": uid,
|
"displayName": f"{uid} {uid}",
|
||||||
"userName": uid,
|
"userName": uid,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -230,7 +230,7 @@ class SCIMUserTests(TestCase):
|
||||||
)
|
)
|
||||||
user = User.objects.create(
|
user = User.objects.create(
|
||||||
username=uid,
|
username=uid,
|
||||||
name=uid,
|
name=f"{uid} {uid}",
|
||||||
email=f"{uid}@goauthentik.io",
|
email=f"{uid}@goauthentik.io",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -254,11 +254,11 @@ class SCIMUserTests(TestCase):
|
||||||
],
|
],
|
||||||
"externalId": user.uid,
|
"externalId": user.uid,
|
||||||
"name": {
|
"name": {
|
||||||
"familyName": "",
|
"familyName": uid,
|
||||||
"formatted": uid,
|
"formatted": f"{uid} {uid}",
|
||||||
"givenName": uid,
|
"givenName": uid,
|
||||||
},
|
},
|
||||||
"displayName": uid,
|
"displayName": f"{uid} {uid}",
|
||||||
"userName": uid,
|
"userName": uid,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,12 +12,14 @@ entries:
|
||||||
expression: |
|
expression: |
|
||||||
# Some implementations require givenName and familyName to be set
|
# Some implementations require givenName and familyName to be set
|
||||||
givenName, familyName = request.user.name, " "
|
givenName, familyName = request.user.name, " "
|
||||||
|
formatted = request.user.name + " "
|
||||||
# This default sets givenName to the name before the first space
|
# This default sets givenName to the name before the first space
|
||||||
# and the remainder as family name
|
# and the remainder as family name
|
||||||
# if the user's name has no space the givenName is the entire name
|
# if the user's name has no space the givenName is the entire name
|
||||||
# (this might cause issues with some SCIM implementations)
|
# (this might cause issues with some SCIM implementations)
|
||||||
if " " in request.user.name:
|
if " " in request.user.name:
|
||||||
givenName, _, familyName = request.user.name.partition(" ")
|
givenName, _, familyName = request.user.name.partition(" ")
|
||||||
|
formatted = request.user.name
|
||||||
|
|
||||||
# photos supports URLs to images, however authentik might return data URIs
|
# photos supports URLs to images, however authentik might return data URIs
|
||||||
avatar = request.user.avatar
|
avatar = request.user.avatar
|
||||||
|
@ -39,7 +41,7 @@ entries:
|
||||||
return {
|
return {
|
||||||
"userName": request.user.username,
|
"userName": request.user.username,
|
||||||
"name": {
|
"name": {
|
||||||
"formatted": request.user.name,
|
"formatted": formatted,
|
||||||
"givenName": givenName,
|
"givenName": givenName,
|
||||||
"familyName": familyName,
|
"familyName": familyName,
|
||||||
},
|
},
|
||||||
|
|
Reference in New Issue