Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Oauth of Github, Google and Microsoft #4298

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
63d5f9b
not working api
feyruzb May 17, 2024
3d6ced1
Backup before OAuth integration changes
feyruzb Jul 3, 2024
74c1202
commit with new version of code ,work in progress
feyruzb Jul 4, 2024
3c0b13f
second backup
feyruzb Jul 17, 2024
d75edbd
github working implementation
feyruzb Jul 18, 2024
47ba1dd
working github implementation , allows everyone to log in
feyruzb Jul 18, 2024
822c626
working impelementation of github Oauth
feyruzb Jul 18, 2024
251f7dd
removed useless server configuration variables, useless debug message…
feyruzb Jul 19, 2024
1394f28
added dynamic path for finding server_config.json
feyruzb Jul 19, 2024
785a0f0
refactored authentication process
feyruzb Jul 22, 2024
be35303
refactored code for config oauth reusability ,improved performace
feyruzb Jul 22, 2024
370908e
updated server config template
feyruzb Jul 22, 2024
9bc3482
added google authentification
feyruzb Jul 24, 2024
422aacb
changed the process of finding which login provider to use , now it s…
feyruzb Jul 25, 2024
feabac5
added documentation for oauth
feyruzb Jul 29, 2024
1967161
fixed a part of mistakes
feyruzb Jul 30, 2024
0b5f571
added mock server, test case
feyruzb Aug 8, 2024
2faf4f2
added test cases and generalized functions, added dynamic appearence …
feyruzb Aug 9, 2024
a9713c9
github is now using email as username
feyruzb Aug 12, 2024
bdbd6b6
fixed cservakt suggestions
feyruzb Sep 3, 2024
1b6c87a
Update docs/web/authentication.md
feyruzb Sep 4, 2024
4ab45de
documentation changed
feyruzb Sep 4, 2024
472efad
Merge branch 'branch-2-backup' of https://github.com/feyruzb/codechec…
feyruzb Sep 4, 2024
3c78f2d
removed unnecessary "oauth" prefix, now provider in auth_string
feyruzb Sep 4, 2024
3e32aa7
working implementation of microsoft OAuth
feyruzb Sep 10, 2024
066ef7b
added FIX ME near workaround
feyruzb Sep 11, 2024
3c83d1e
added FIX ME near workaround
feyruzb Sep 11, 2024
77f6fc5
added state check against stolen session
feyruzb Sep 18, 2024
d5c9a8c
fixed half the problems from review
feyruzb Sep 20, 2024
fc930b3
changed syntaxis to much the rest of the file, added a check for defa…
feyruzb Sep 23, 2024
ff7c83f
not working api
feyruzb May 17, 2024
8ef45dd
Backup before OAuth integration changes
feyruzb Jul 3, 2024
0f02c88
commit with new version of code ,work in progress
feyruzb Jul 4, 2024
d50718d
second backup
feyruzb Jul 17, 2024
2050b3c
github working implementation
feyruzb Jul 18, 2024
cd7d61f
working github implementation , allows everyone to log in
feyruzb Jul 18, 2024
7095028
working impelementation of github Oauth
feyruzb Jul 18, 2024
e72c224
removed useless server configuration variables, useless debug message…
feyruzb Jul 19, 2024
b501310
added dynamic path for finding server_config.json
feyruzb Jul 19, 2024
0066143
refactored authentication process
feyruzb Jul 22, 2024
99f07b5
refactored code for config oauth reusability ,improved performace
feyruzb Jul 22, 2024
2ffe925
updated server config template
feyruzb Jul 22, 2024
1f0692d
added google authentification
feyruzb Jul 24, 2024
85f7d63
changed the process of finding which login provider to use , now it s…
feyruzb Jul 25, 2024
95288d3
added documentation for oauth
feyruzb Jul 29, 2024
dd77fbb
fixed a part of mistakes
feyruzb Jul 30, 2024
e1d47e1
added mock server, test case
feyruzb Aug 8, 2024
c286c7c
added test cases and generalized functions, added dynamic appearence …
feyruzb Aug 9, 2024
9ba1d12
github is now using email as username
feyruzb Aug 12, 2024
ec3be0a
fixed cservakt suggestions
feyruzb Sep 3, 2024
993cf33
documentation changed
feyruzb Sep 4, 2024
87731a4
Update docs/web/authentication.md
feyruzb Sep 4, 2024
05e58db
removed unnecessary "oauth" prefix, now provider in auth_string
feyruzb Sep 4, 2024
40f8a07
working implementation of microsoft OAuth
feyruzb Sep 10, 2024
71e35c5
added FIX ME near workaround
feyruzb Sep 11, 2024
09f49c4
added FIX ME near workaround
feyruzb Sep 11, 2024
a8a1503
added state check against stolen session
feyruzb Sep 18, 2024
0b2d7b3
fixed half the problems from review
feyruzb Sep 20, 2024
c8e0c3a
changed syntaxis to much the rest of the file, added a check for defa…
feyruzb Sep 23, 2024
ebd1aa3
Merge branch 'branch-2-backup' of https://github.com/feyruzb/codechec…
feyruzb Sep 24, 2024
9595370
Merge branch 'Ericsson:master' into branch-2-backup
feyruzb Sep 24, 2024
5256b0e
Merge branch 'branch-2-backup' of https://github.com/feyruzb/codechec…
feyruzb Sep 24, 2024
e37683a
tests check
feyruzb Sep 24, 2024
4a5c76b
fixed bug of invalid authentication
feyruzb Sep 24, 2024
93e0605
fixed Username:Password vulnerability of accepting illegal OAuth format
feyruzb Sep 25, 2024
afb9323
added try catches for AUTHLIB functions
feyruzb Sep 25, 2024
c99d550
log in different devices with the same username in the same session
feyruzb Sep 26, 2024
cc9ce96
removed session reuse, added server side state check
feyruzb Oct 1, 2024
6a44b25
testing test cases
feyruzb Oct 3, 2024
c96c10d
Merge branch 'Ericsson:master' into branch-2-backup
feyruzb Oct 7, 2024
b71af06
test of new table in database and check try
feyruzb Oct 14, 2024
152f0d9
working implementation of state check
feyruzb Oct 15, 2024
d6561b8
aded new column in auth_sessions for storing access_token for later v…
feyruzb Oct 15, 2024
21d3a8a
Merge branch 'Ericsson:master' into branch-2-backup
feyruzb Oct 16, 2024
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
113 changes: 106 additions & 7 deletions docs/web/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Table of Contents
* [<i>LDAP</i> authentication](#ldap-authentication)
* [Configuration options](#configuration-options)
* Membership in custom groups with [<i>regex_groups</i>](#regex_groups-authentication)
* [<i>OAuth</i> authentication](#oauth-authentication)
* [<i>OAuth</i> Configuration options](#oauth-configuration-options)
* [<i>OAuth</i> details per each provider](#oauth-details-per-each-provider)
* [Client-side configuration](#client-side-configuration)
* [Web-browser client](#web-browser-client)
* [Command-line client](#command-line-client)
Expand All @@ -39,31 +42,31 @@ is handled.
* `enabled`

Setting this to `false` disables privileged access

* `realm_name`

The name to show for web-browser viewers' pop-up login window via
*HTTP Authenticate*

* `realm_error`

The error message shown in the browser when the user fails to authenticate

* `logins_until_cleanup`

After this many login attempts made towards the server, it will perform an
automatic cleanup of old, expired sessions.
This option can be changed and reloaded without server restart by using the
`--reload` option of CodeChecker server command.

* `session_lifetime`

(in seconds) The lifetime of the session sets that after this many seconds
since last session access the session is permanently invalidated.

This option can be changed and reloaded without server restart by using the
`--reload` option of CodeChecker server command.

* `refresh_time`

(in seconds) Refresh time of the local session objects. We use local session
Expand Down Expand Up @@ -243,12 +246,12 @@ servers as it can elongate the authentication process.
* `groupPattern`

Group query pattern used LDAP query expression to find the group objects
a user is a member of. It must contain a `$USERDN$` pattern.
a user is a member of. It must contain a `$USERDN$` pattern.
`$USERDN$` will be automatically replaced by the queried user account DN.

* `groupNameAttr`

The attribute of the group object which contains the name of the group.
The attribute of the group object which contains the name of the group.

* `groupScope`

Expand Down Expand Up @@ -320,6 +323,102 @@ groups. For more information [see](permissions.md#managing-permissions).

----

### <i>OAUTH</i> authentication <a name="oauth-authentication"></a>

CodeChecker also supports OAUTH-based authentication. The `authentication.method_oauth` section contains the configuration for OAUTH authentication for different OAUTH providers. The server can be configured for different Oauth `providers`. Users can be added into the `allowed_users`.

#### OAUTH Configuration options <a name="oauth-configuration-options"></a>
* `enabled`

Indicated if OAUTH authentication is enabled (required for any methods below)

* `providers`

The provider field contains configuration details for OAuth providers. Each provider's configuration includes but may vary depending on provider:
feyruzb marked this conversation as resolved.
Show resolved Hide resolved

* `provider_name` as an object containing following properties:

* `enabled`

Indicates if current provider is enabled (github, google, etc)

* `oauth_client_id`

Contains client ID provided by the OAuth provider.

* `oauth_client_secret`

The client secret must be provided by the OAuth provider.

* `oauth_authorization_uri`

This link in used for redirecting user for provider's authentication page

* `oauth_redirect_uri`

User will be redirected back to the provided link after login with returned data.

* `oauth_token_uri`

The URI to exchange the authorization code for an access token.

* `oauth_user_info_uri`

The URI to fetch the authenticated user's information.

* `oauth_scope`

The scope of access requested from the OAuth provider.

* `oauth_user_info_mapping`

A mapping of user info fields from the provider to local fields.

* `username`

Field for the username.
* `email`

Field for the email.
* `fullname`

Field for the fullname.
* `allowed_users`

list of approved usernames independently specified per each provider
~~~{.json}
"method_oauth": {
"enabled": false,
"providers": {
"example_provider": {
"enabled": false,
"oauth_client_id": "client id",
"oauth_client_secret": "client secret",
"oauth_authorization_uri": "https://accounts.google.com/o/oauth2/auth",
"oauth_redirect_uri": "http://localhost:8080/login",
"oauth_token_uri": "https://accounts.google.com/o/oauth2/token",
"oauth_user_info_uri": "https://www.googleapis.com/oauth2/v1/userinfo",
"oauth_scope": "openid email profile",
"oauth_user_info_mapping": {
"username": "email",
"email": "email",
"fullname": "name"
},
"allowed_users": [
"user1",
"user2",
"user3"
]
}
}
}
~~~

#### Oauth Details per each provider <a name ="oauth-details-per-each-provider"></a>

* Important: 'oauth_redirect_uri' must always match with link specified in the
Providers settings when issuing an access token.

# Client-side configuration <a name="client-side-configuration"></a>

## Web-browser client <a name="web-browser-client"></a>
Expand Down
7 changes: 7 additions & 0 deletions web/api/authentication.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ service codeCheckerAuthentication {
string performLogin(1: string authMethod,
2: string authString)
throws (1: codechecker_api_shared.RequestFailed requestError),

// Returns list of providers for oauth for respective appearence of buttons.
list<string> getOauthProviders(),

// Create a link for the user to log in for github Oauth.
string createLink(1: string provider)
throws (1: codechecker_api_shared.RequestFailed requestError),

// Performs logout action for the user. Must be called from the
// corresponding valid session which is to be destroyed.
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/js/codechecker-api-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codechecker-api",
"version": "6.58.0",
"version": "6.59.0",
"description": "Generated node.js compatible API stubs for CodeChecker server.",
"main": "lib",
"homepage": "https://github.com/Ericsson/codechecker",
Expand Down
Binary file modified web/api/py/codechecker_api/dist/codechecker_api.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/py/codechecker_api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open('README.md', encoding='utf-8', errors="ignore") as f:
long_description = f.read()

api_version = '6.58.0'
api_version = '6.59.0'

setup(
name='codechecker_api',
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion web/api/py/codechecker_api_shared/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open('README.md', encoding='utf-8', errors="ignore") as f:
long_description = f.read()

api_version = '6.58.0'
api_version = '6.59.0'

setup(
name='codechecker_api_shared',
Expand Down
2 changes: 1 addition & 1 deletion web/client/codechecker_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import getpass
import sys

feyruzb marked this conversation as resolved.
Show resolved Hide resolved
from thrift.Thrift import TApplicationException


import codechecker_api_shared
from codechecker_api.Authentication_v6 import ttypes as AuthTypes

Expand Down
8 changes: 8 additions & 0 deletions web/client/codechecker_client/helpers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def getAccessControl(self):
def performLogin(self, auth_method, auth_string):
pass

@thrift_client_call
def createLink(self, provider):
feyruzb marked this conversation as resolved.
Show resolved Hide resolved
pass

@thrift_client_call
def getOauthProviders(self):
pass

@thrift_client_call
def destroySession(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion web/codechecker_web/shared/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The newest supported minor version (value) for each supported major version
# (key) in this particular build.
SUPPORTED_VERSIONS = {
6: 58
6: 59
}

# Used by the client to automatically identify the latest major and minor
Expand Down
2 changes: 2 additions & 0 deletions web/requirements_py/auth/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
python-ldap==3.4.0
python-pam==1.8.4
Authlib==1.3.1
requests==2.32.3
Loading
Loading