Skip to content

Commit d3f6b29

Browse files
committed
added documentation for oauth
1 parent 8f9a467 commit d3f6b29

File tree

6 files changed

+152
-26
lines changed

6 files changed

+152
-26
lines changed

analyzer/tools/build-logger/ldlogger

-38.4 KB
Binary file not shown.
-38.5 KB
Binary file not shown.

docs/web/authentication.md

+140-17
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ the results stored on a server.
99
1010
Table of Contents
1111
=================
12-
* [Server-side configuration](#server-side-configuration)
13-
* [<i>Dictionary</i> authentication](#dictionary-authentication)
14-
* [External authentication methods](#external-auth-methods)
15-
* [<i>PAM</i> authentication](#pam-authentication)
16-
* [<i>LDAP</i> authentication](#ldap-authentication)
17-
* [Configuration options](#configuration-options)
18-
* Membership in custom groups with [<i>regex_groups</i>](#regex_groups-authentication)
19-
* [Client-side configuration](#client-side-configuration)
20-
* [Web-browser client](#web-browser-client)
21-
* [Command-line client](#command-line-client)
22-
* [Preconfigured credentials](#preconfigured-credentials)
23-
* [Automatic login](#automatic-login)
24-
* [Currently active tokens](#currently-active-tokens)
25-
* [Personal access token](#personal-access-token)
26-
* [`new`](#new-personal-access-token)
27-
* [`list`](#list-personal-access-token)
28-
* [`del`](#remove-personal-access-token)
12+
- [CodeChecker authentication subsystem](#codechecker-authentication-subsystem)
13+
- [Table of Contents](#table-of-contents)
14+
- [Server-side configuration ](#server-side-configuration-)
15+
- [Dictionary authentication ](#dictionary-authentication-)
16+
- [External authentication methods ](#external-authentication-methods-)
17+
- [PAM authentication ](#pam-authentication-)
18+
- [LDAP authentication ](#ldap-authentication-)
19+
- [Configuration options ](#configuration-options-)
20+
- [Membership in custom groups with regex\_groups](#membership-in-custom-groups-with-regex_groups)
21+
- [OAUTH authentication ](#oauth-authentication-)
22+
- [OAUTH Configuration options ](#oauth-configuration-options-)
23+
- [Details per each provider ](#details-per-each-provider-)
24+
- [Client-side configuration ](#client-side-configuration-)
25+
- [Web-browser client ](#web-browser-client-)
26+
- [Command-line client ](#command-line-client-)
27+
- [Preconfigured credentials ](#preconfigured-credentials-)
28+
- [Automatic login ](#automatic-login-)
29+
- [Currently active tokens ](#currently-active-tokens-)
30+
- [Personal access token ](#personal-access-token-)
31+
- [New personal access token ](#new-personal-access-token-)
32+
- [List personal access tokens ](#list-personal-access-tokens-)
33+
- [Remove personal access token ](#remove-personal-access-token-)
2934

3035
# Server-side configuration <a name="server-side-configuration"></a>
3136

@@ -320,6 +325,124 @@ groups. For more information [see](permissions.md#managing-permissions).
320325

321326
----
322327

328+
### <i>OAUTH</i> authentication <a name="oauth-authentication"></a>
329+
330+
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`
331+
332+
#### OAUTH Configuration options <a name="oauth-configuration-options"></a>
333+
* `enabled`
334+
335+
Indicated if OAUTH method is enabled
336+
337+
* `providers`
338+
339+
The provider field contains configuration details for OAuth providers. Each provider's configuration includes but may vary depending on provider:
340+
341+
* `enabled`
342+
343+
Indicates if the Oauth provider is enabled
344+
345+
* `oauth_client_id`
346+
347+
Contains client ID provided by the OAuth provider.
348+
349+
350+
* `oauth_client_secret`
351+
352+
The client secret provided by the OAuth provider.
353+
354+
* `oauth_authorization_uri`
355+
356+
This link in used for redirecting user for perovider's authentication page
357+
358+
* `oauth_redirect_uri`
359+
360+
The oauth_redirect_uri URI to which the OAuth provider will redirect after authorization and in some providers used for confirming the redirection URI.
361+
362+
* `oauth_token_uri`
363+
364+
The URI to exchange the authorization code for an access token.
365+
366+
* `oauth_user_info_uri`
367+
368+
The URI to fetch the authenticated user's information.
369+
370+
* `oauth_scope`
371+
372+
The scope of access requested from the OAuth provider.
373+
374+
* `oauth_user_info_mapping`
375+
376+
A mapping of user info fields from the provider to local fields.
377+
378+
* `username`
379+
380+
Field for the username.
381+
* `email`
382+
383+
Field for the email.
384+
* `fullname`
385+
386+
Field for the fullname.
387+
* `allowed_users`
388+
389+
A list of allowed users differently configured for each provider
390+
391+
~~~{.json}
392+
"method_oauth": {
393+
"enabled": false,
394+
"providers": {
395+
"github": {
396+
"enabled": false,
397+
"oauth_client_id": "client id",
398+
"oauth_client_secret": "client secret",
399+
"oauth_authorization_uri": "https://github.com/login/oauth/authorize",
400+
"oauth_token_uri": "https://github.com/login/oauth/access_token",
401+
"oauth_user_info_uri": "https://api.github.com/user",
402+
"oauth_scope": "openid email profile",
403+
"oauth_user_info_mapping": {
404+
"username": "login",
405+
"email": "email",
406+
"fullname": "name"
407+
},
408+
"allowed_users": [
409+
"user1",
410+
"user2",
411+
"user3"
412+
]
413+
},
414+
"google": {
415+
"enabled": false,
416+
"oauth_client_id": "client id",
417+
"oauth_client_secret": "client secret",
418+
"oauth_authorization_uri": "https://accounts.google.com/o/oauth2/auth",
419+
"oauth_redirect_uri": "http://localhost:8080/login",
420+
"oauth_token_uri": "https://accounts.google.com/o/oauth2/token",
421+
"oauth_user_info_uri": "https://www.googleapis.com/oauth2/v1/userinfo",
422+
"oauth_scope": "openid email profile",
423+
"oauth_user_info_mapping": {
424+
"username": "email",
425+
"email": "email",
426+
"fullname": "name"
427+
},
428+
"allowed_users": [
429+
"user1",
430+
"user2",
431+
"user3"
432+
]
433+
}
434+
}
435+
}
436+
~~~
437+
438+
#### Details per each provider <a name ="details-per-each-provider"></a>
439+
440+
* For Google OAuth to function correctly, the `oauth_redirect_uri` in application's configuration must exactly match the `Authorized redirect URIs` specified in the Google API Console.
441+
442+
* For GitHub to redirect correctly, set the `Authorization callback URL` to the login page of CodeChecker. This ensures proper processing of the authorization. Additionally, set the homepage URL to the homepage of CodeChecker.
443+
444+
445+
323446
# Client-side configuration <a name="client-side-configuration"></a>
324447

325448
## Web-browser client <a name="web-browser-client"></a>

web/server/codechecker_server/api/authentication.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def createLinkGoogle(self):
137137
scope = oauth_config["oauth_scope"]
138138
authorization_uri = oauth_config["oauth_authorization_uri"]
139139
redirect_uri = oauth_config["oauth_redirect_uri"]
140-
token_uri = oauth_config["oauth_token_uri"]
141140

142141

143142
# Create an OAuth2Session instance
@@ -242,6 +241,7 @@ def performLogin(self, auth_method, auth_string):
242241
scope = oauth_config["oauth_scope"]
243242
token_url = oauth_config["oauth_token_uri"]
244243
user_info_url = oauth_config["oauth_user_info_uri"]
244+
245245

246246
session = OAuth2Session(client_id, client_secret, scope=scope)
247247
token = session.fetch_token(
@@ -290,6 +290,7 @@ def performLogin(self, auth_method, auth_string):
290290
"User is not authorized to access this service.")
291291

292292
session = self.__manager.create_session("google@" + email + ":" + token['access_token'])
293+
293294
return session.token
294295

295296
raise codechecker_api_shared.ttypes.RequestFailed(

web/server/config/server_config.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@
5050
"providers": {
5151
"github": {
5252
"enabled": false,
53-
"oauth_client_id": "example_id",
54-
"oauth_client_secret": "example_secret",
55-
"oauth_redirect_uri": "http://localhost:8001/login",
53+
"oauth_client_id": "client id",
54+
"oauth_client_secret": "client secret",
5655
"oauth_authorization_uri": "https://github.com/login/oauth/authorize",
5756
"oauth_token_uri": "https://github.com/login/oauth/access_token",
5857
"oauth_user_info_uri": "https://api.github.com/user",
59-
"oauth_scope": "user:email",
58+
"oauth_scope": "openid email profile",
6059
"oauth_user_info_mapping": {
6160
"username": "login",
6261
"email": "email",
@@ -70,12 +69,13 @@
7069
},
7170
"google": {
7271
"enabled": false,
73-
"oauth_client_id": "example_id",
74-
"oauth_client_secret": "example_secret",
72+
"oauth_client_id": "client id",
73+
"oauth_client_secret": "client secret",
7574
"oauth_authorization_uri": "https://accounts.google.com/o/oauth2/auth",
76-
"oauth_token_uri": "https://oauth2.googleapis.com/token",
75+
"oauth_redirect_uri": "http://localhost:8080/login",
76+
"oauth_token_uri": "https://accounts.google.com/o/oauth2/token",
7777
"oauth_user_info_uri": "https://www.googleapis.com/oauth2/v1/userinfo",
78-
"oauth_scope": "https://www.googleapis.com/auth/userinfo.email",
78+
"oauth_scope": "openid email profile",
7979
"oauth_user_info_mapping": {
8080
"username": "email",
8181
"email": "email",

web/server/vue-cli/src/views/Login.vue

+2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ export default {
152152
153153
const url = new URL(window.location.href);
154154
let code = null, state = null;
155+
//get the code and state from the url
155156
code = url.searchParams.get("code");
156157
state = url.searchParams.get("state");
158+
//get the provider from the cookie
157159
const provider = document.cookie.split(";").find(
158160
c => c.includes("oauth_provider")).split("=")[1];
159161

0 commit comments

Comments
 (0)