Skip to content

Commit cf12ab5

Browse files
committed
WIP: support for GitLab kerberos
1 parent 5c3d9ab commit cf12ab5

3 files changed

Lines changed: 45 additions & 4 deletions

File tree

Pipfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
check-manifest = ">=0.25"
8+
9+
[packages]
10+
invenio-app-rdm = {version = "~=14.0.0b1.dev3", extras = ["opensearch2"]}
11+
invenio-checks = ">=2.0.0,<3.0.0"
12+
invenio-collections = "==1.1.0" # see https://github.com/inveniosoftware/invenio-app-rdm/issues/3194
13+
invenio-vocabularies = {version=">=9.0.0,<10.0.0", extras = ["s3fs"]}
14+
invenio-preservation-sync = "==0.2.0"
15+
invenio-cern-sync = {git = "https://github.com/cerndocumentserver/invenio-cern-sync.git", ref = "v0.3.0"}
16+
cds-rdm = {editable=true, path="./site"}
17+
sentry-sdk = ">=1.45,<2.0.0"
18+
lxml = ">=4.6.5"
19+
ipython = "!=8.1.0"
20+
uwsgi = ">=2.0"
21+
uwsgitop = ">=0.11"
22+
uwsgi-tools = ">=1.1.1"
23+
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"
27+
28+
[requires]
29+
python_version = "3.9"
30+
31+
[pipenv]
32+
allow_prereleases = false

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': 'username@CERN.CH', '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)