Skip to content

Commit 3d42ad5

Browse files
committed
WIP: support for GitLab kerberos
1 parent acb126b commit 3d42ad5

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ uwsgi = ">=2.0"
2121
uwsgitop = ">=0.11"
2222
uwsgi-tools = ">=1.1.1"
2323
flask-mail = ">=0.9.0,<0.10.0"
24+
invenio-preservation-sync = "==0.2.0"
25+
invenio-cern-sync = {git = "https://github.com/cerndocumentserver/invenio-cern-sync.git", ref = "v0.3.0"}
26+
invenio-vcs = ">=4.0.0,<5.0.0"
2427

2528
[requires]
2629
python_version = "3.9"

site/cds_rdm/errors.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def __init__(self, user_id: str) -> None:
2929

3030
class GitLabIdentityNotFoundError(Exception):
3131
def __init__(self, user_id: str) -> None:
32-
super().__init__(_(f"GitLab user {user_id} did not have CERN SSO identity"))
32+
super().__init__(
33+
_(
34+
f"GitLab user {user_id} did not have CERN OpenID or Kerberos identity (LDAP-only accounts are not supported)"
35+
)
36+
)
3337

3438

3539
class KeycloakGitLabMismatchError(Exception):

site/cds_rdm/vcs/handlers.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ def inner(remote, resp, user_info, **kwargs):
2929
gl_identities = user_info["identities"]
3030
gl_extern_uid: str | None = None
3131
for identity in gl_identities:
32-
if identity["provider"] != "openid_connect":
32+
prov = identity["provider"]
33+
34+
if prov == "openid_connect":
35+
gl_extern_uid = identity["extern_uid"]
36+
elif prov == "kerberos":
37+
# {'provider': 'kerberos', 'extern_uid': '[email protected]', 'saml_provider_id': None}
38+
gl_extern_uid = identity["extern_uid"].removesuffix("@CERN.CH")
39+
else:
3340
continue
3441

35-
gl_extern_uid = identity["extern_uid"]
36-
3742
if gl_extern_uid is None:
3843
raise GitLabIdentityNotFoundError(gl_user_id)
3944

0 commit comments

Comments
 (0)