Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/web/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ Specific behavior related to each provider is configured by a provider `template
* `username` - Company's signum will be the user's identifier.
* `email` - an email associated with this Microsoft account will be used as user's identifier.

`gitlab/v1`
* `username` - the username the user prefers to be referred to as, usually their login or the login from the authentication provider.
* `email` - an email associated with this Gitlab account will be used as user's identifier.
* `name` - user's full name.

The properties below are automatically set by templates, but can be overridden for testing purposes, and when using a custom OAuth provider.

* `callback_url`
Expand Down
10 changes: 10 additions & 0 deletions web/codechecker_web/server/oauth_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,15 @@
"user_info_mapping": {
"username": "email"
}
},
"gitlab/v1": {
"authorization_url": "https://gitlab.com/oauth/authorize",
"callback_url": "{host}/login/OAuthLogin/{provider}",
"token_url": "https://gitlab.com/oauth/token",
"user_info_url": "https://gitlab.com/oauth/userinfo",
"scope": "openid email profile",
"user_info_mapping": {
"username": "email"
}
}
}
8 changes: 7 additions & 1 deletion web/server/codechecker_server/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,15 @@ def performLogin(self, auth_method, auth_string):
username = claims.get("Signum")
else:
username = user_info.get("mail")
elif template == "gitlab/v1":
if username_key == "username":
username = user_info.get("preferred_username")
elif username_key == "email":
username = user_info.get("email")
elif username_key == "name":
username = user_info.get("name")

LOG.debug(f"groups fetched for {username}, are: {groups}")

LOG.info("Username fetched, for username: %s", username)
except Exception as ex:
LOG.error("Username fetch failed: %s", str(ex))
Expand Down
11 changes: 11 additions & 0 deletions web/server/config/server_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@
"variables": {
"tenant_id": "common"
}
},
"gitlab": {
"enabled": false,
"client_id": "<ExampleClientID>",
"client_secret": "<ExampleClientSecret>",
"template": "gitlab/v1",
"variables": {
"authorization_url": "https://gitlab.custom.com/oauth/authorize",
"token_url": "https://gitlab.custom.com/oauth/token",
"user_info_url": "https://gitlab.custom.com/oauth/userinfo"
}
}
}
},
Expand Down
Loading