|
1 | 1 | .. _authentication: |
| 2 | + |
2 | 3 | Authentication |
3 | 4 | ============== |
4 | 5 |
|
5 | | -Protecting your Flower instance from unwarranted access is important |
6 | | -if it runs in an untrusted environment. Below, we outline the various |
7 | | -forms of authentication supported by Flower. |
| 6 | +Flower supports a variety of authentication methods, including Basic Authentication, Google, GitHub, |
| 7 | +GitLab, and Okta OAuth. You can also customize and use your own authentication method. |
8 | 8 |
|
9 | | -**NOTE:** The following endpoints are exempt from authentication: |
| 9 | +The following endpoints are exempt from authentication: |
10 | 10 |
|
11 | 11 | - /healthcheck |
12 | 12 | - /metrics |
13 | 13 |
|
14 | | -.. _basic-auth: |
| 14 | +.. _basic-authentication: |
15 | 15 |
|
16 | 16 | HTTP Basic Authentication |
17 | 17 | ------------------------- |
18 | 18 |
|
19 | | -Securing Flower with Basic Authentication is easy. |
| 19 | +Flower supports Basic Authentication as a built-in authentication method, allowing you to secure access to the |
| 20 | +Flower using simple username and password credentials. This authentication method is commonly used for |
| 21 | +straightforward authentication requirements. |
| 22 | + |
| 23 | +To enable basic authentication, use :ref:`basic_auth` option. This option allows you to specify a list of |
| 24 | +username and password pairs for authentication. |
20 | 25 |
|
21 | | -The `--basic_auth` option accepts `user:password` pairs separated by |
22 | | -a comma. If configured, any client trying to access this |
23 | | -Flower instance will be prompted to provide the credentials specified in |
24 | | -this argument: :: |
| 26 | +For example, running Flower with the following :ref:`basic_auth` option will protect the Flower UI and |
| 27 | +only allow access to users providing the username user and the password pswd:: |
25 | 28 |
|
26 | | - $ celery flower --basic_auth=user1:password1,user2:password2 |
| 29 | + $ celery flower --basic-auth=user:pswd |
27 | 30 |
|
28 | 31 | See also :ref:`reverse-proxy` |
29 | 32 |
|
30 | 33 | .. _google-oauth: |
31 | 34 |
|
32 | | -Google OAuth 2.0 |
33 | | ----------------- |
| 35 | +Google OAuth |
| 36 | +------------ |
| 37 | + |
| 38 | +Flower provides authentication support using Google OAuth, enabling you to authenticate users through their Google accounts. |
| 39 | +This integration simplifies the authentication process and offers a seamless experience for users who are already logged into Google. |
34 | 40 |
|
35 | | -Flower supports Google OAuth 2.0. This way you can authenticate any user |
36 | | -with a Google account. Google OAuth 2.0 authentication is enabled using the |
37 | | -`--auth`, `--oauth2_key`, `--oauth2_secret` and `--oauth2_redirect_uri` options. |
| 41 | +Follow the steps below to configure and use Google OAuth authentication: |
38 | 42 |
|
39 | | -`--auth` is a regular expression, for granting access only to the specified email pattern. |
40 | | -`--oauth2_key` and `--oauth2_secret` are your credentials from your `Google Developer Console`_. |
41 | | -`--oauth2_redirect_uri` is there to specify what is the redirect_uri associated to your key and secret |
| 43 | +1. Go to the `Google Developer Console`_ |
| 44 | +2. Select a project, or create a new one. |
| 45 | +3. In the sidebar on the left, select Credentials. |
| 46 | +4. Click CREATE CREDENTIALS and click OAuth client ID. |
| 47 | +5. Under Application type, select Web application. |
| 48 | +6. Name OAuth 2.0 client and click Create. |
| 49 | +7. Copy the "Client secret" and "Client ID" |
| 50 | +8. Add redirect URI to the list of Authorized redirect URIs |
42 | 51 |
|
43 | | -For instance, if you want to grant access to `[email protected]` and `[email protected]`: :: |
| 52 | +Here's an example configuration file with the Google OAuth options: |
44 | 53 |
|
45 | | - $ celery flower --auth="[email protected]|[email protected]" --oauth2_key=... --oauth2_secret=... --oauth2_redirect_uri=http://flower.example.com/login |
| 54 | +.. code-block:: python |
46 | 55 |
|
47 | | -Alternatively, you can set environment variables instead of command line arguments: :: |
| 56 | + auth_provider="flower.views.auth.GoogleAuth2LoginHandler" |
| 57 | + auth="allowed-emails.*@gmail.com" |
| 58 | + oauth2_key="<your_client_id>" |
| 59 | + oauth2_secret="<your_client_secret>" |
| 60 | + oauth2_redirect_uri="http://localhost:5555/login" |
48 | 61 |
|
49 | | - $ export FLOWER_OAUTH2_KEY=... |
50 | | - $ export FLOWER_OAUTH2_SECRET=... |
51 | | - $ export FLOWER_OAUTH2_REDIRECT_URI=http://flower.example.com/login |
52 | | - $ celery flower --auth=.*@example\.com |
| 62 | +Replace `<your_client_id>` and `<your_client_secret>` with the actual Client ID and secret obtained from |
| 63 | +the Google Developer Console. |
53 | 64 |
|
54 | 65 | .. _Google Developer Console: https://console.developers.google.com |
55 | 66 |
|
56 | 67 | .. _github-oauth: |
57 | 68 |
|
58 | | -Okta OAuth |
| 69 | +GitHub OAuth |
59 | 70 | ------------ |
60 | 71 |
|
61 | | -Flower also supports Okta OAuth. Flower should be registered in |
62 | | -<https://developer.okta.com/docs/guides/add-an-external-idp/openidconnect/register-app-in-okta/> |
63 | | -before getting started. See `Okta OAuth API`_ docs for more info. |
| 72 | +Flower also supports GitHub OAuth. Before getting started, Flower should be registered in |
| 73 | +`Github Settings`_. |
64 | 74 |
|
65 | | -Okta OAuth should be activated using `--auth_provider` option. |
66 | | -The client id, secret and redirect uri should be provided using |
67 | | -`--oauth2_key`, `--oauth2_secret`, `--oauth2_redirect_uri` options or using |
68 | | -`FLOWER_OAUTH2_KEY`, `FLOWER_OAUTH2_SECRET`, `FLOWER_OAUTH2_REDIRECT_URI` environment variables. |
| 75 | +Github OAuth is activated by setting :ref:`auth_provider` to `flower.views.auth.GithubLoginHandler`. |
| 76 | +Here's an example configuration file with the Github OAuth options: |
69 | 77 |
|
70 | | - The URL from which OAuth2 API URLs will be built should be set using `FLOWER_OAUTH2_OKTA_BASE_URL` |
71 | | - environment variable: :: |
| 78 | +.. code-block:: python |
72 | 79 |
|
73 | | - $ export FLOWER_OAUTH2_KEY=7956724aafbf5e1a93ac |
74 | | - $ export FLOWER_OAUTH2_SECRET=f9155f764b7e466c445931a6e3cc7a42c4ce47be |
75 | | - $ export FLOWER_OAUTH2_REDIRECT_URI=http://localhost:5555/login |
76 | | - $ export FLOWER_OAUTH2_OKTA_BASE_URL=https://my-company.okta.com/oauth2 |
77 | | - $ celery flower --auth_provider=flower.views.auth.OktaLoginHandler --auth=.*@example\.com |
| 80 | + auth_provider="flower.views.auth.GithubLoginHandler" |
| 81 | + auth="allowed-emails.*@gmail.com" |
| 82 | + oauth2_key="<your_client_id>" |
| 83 | + oauth2_secret="<your_client_secret>" |
| 84 | + oauth2_redirect_uri="http://localhost:5555/login" |
78 | 85 |
|
79 | | -.. _Okta OAuth API: https://developer.okta.com/docs/reference/api/oidc/ |
| 86 | +Replace `<your_client_id>` and `<your_client_secret>` with the actual Client ID and secret obtained from |
| 87 | +the Github Settings. |
80 | 88 |
|
81 | | -GitHub OAuth |
82 | | ------------- |
83 | | - |
84 | | -Flower also supports GitHub OAuth. Flower should be registered in |
85 | | -<https://github.com/settings/applications/new> before getting started. |
86 | 89 | See `GitHub OAuth API`_ docs for more info. |
87 | 90 |
|
88 | | -GitHub OAuth should be activated using `--auth_provider` option. |
89 | | -The client id, secret and redirect uri should be provided using |
90 | | -`--oauth2_key`, `--oauth2_secret` and `--oauth2_redirect_uri` options or using |
91 | | -`FLOWER_OAUTH2_KEY`, `FLOWER_OAUTH2_SECRET` and `FLOWER_OAUTH2_REDIRECT_URI` |
92 | | -environment variables. :: |
| 91 | +.. _Github Settings: https://github.com/settings/applications/new |
| 92 | +.. _GitHub OAuth API: https://developer.github.com/v3/oauth/ |
93 | 93 |
|
94 | | - $ export FLOWER_OAUTH2_KEY=7956724aafbf5e1a93ac |
95 | | - $ export FLOWER_OAUTH2_SECRET=f9155f764b7e466c445931a6e3cc7a42c4ce47be |
96 | | - $ export FLOWER_OAUTH2_REDIRECT_URI=http://localhost:5555/login |
97 | | - $ celery flower --auth_provider=flower.views.auth.GithubLoginHandler --auth=.*@example\.com |
| 94 | +.. _okta-oauth: |
98 | 95 |
|
99 | | -.. _GitHub OAuth API: https://developer.github.com/v3/oauth/ |
| 96 | +Okta OAuth |
| 97 | +---------- |
100 | 98 |
|
101 | | -.. _gitlab-oauth: |
| 99 | +Flower also supports Okta OAuth. Before getting started, you need to register Flower in `Okta`_. |
| 100 | +Okta OAuth is activated by setting :ref:`auth_provider` option to `flower.views.auth.OktaLoginHandler`. |
| 101 | + |
| 102 | +Okta OAuth requires `oauth2_key`, `oauth2_secret` and `oauth2_redirect_uri` options which should be obtained from Okta. |
| 103 | +Okta OAuth also uses `FLOWER_OAUTH2_OKTA_BASE_URL` environment variable. |
| 104 | + |
| 105 | +See Okta `Okta OAuth API`_ docs for more info. |
102 | 106 |
|
103 | | -**NOTE:** If you need a custom GitHub Domain, please export it using environment variable: |
104 | | -`export FLOWER_GITHUB_OAUTH_DOMAIN=github.foobar.com` |
| 107 | +.. _Okta: https://developer.okta.com/docs/guides/add-an-external-idp/openidconnect/main/ |
| 108 | +.. _Okta OAuth API: https://developer.okta.com/docs/reference/api/oidc/ |
| 109 | + |
| 110 | +.. _gitlab-oauth: |
105 | 111 |
|
106 | 112 | GitLab OAuth |
107 | 113 | ------------ |
108 | 114 |
|
109 | | -Flower also supports GitLab OAuth. Flower should be registered in |
110 | | -<https://gitlab.com/profile/applications> before getting started. |
111 | | -See `GitLab OAuth2 API`_ docs for more info. |
| 115 | +Flower also supports GitLab OAuth for authentication. To enable GitLab OAuth, follow the steps below: |
112 | 116 |
|
113 | | -GitLab OAuth should be activated using `--auth_provider` option. |
114 | | -The client id, secret and redirect uri should be provided using |
115 | | -`--oauth2_key`, `--oauth2_secret` and `--oauth2_redirect_uri` options or using |
116 | | -`FLOWER_OAUTH2_KEY`, `FLOWER_OAUTH2_SECRET` and `FLOWER_OAUTH2_REDIRECT_URI` |
117 | | -environment variables. |
| 117 | +1. Register Flower as an application at GitLab. You can refer to the `GitLab OAuth documentation`_ for detailed instructions on how to do this. |
| 118 | +2. Once registered, you will obtain the credentials for Flower configuration. |
| 119 | +3. In your Flower configuration, set the following options to activate GitLab OAuth: |
| 120 | + - :ref:`auth_provider` to `flower.views.auth.GitlabLoginHandler`. |
| 121 | + - :ref:`oauth2_key` to the "Application ID" obtained from GitLab. |
| 122 | + - :ref:`oauth2_secret` to the "Secret" obtained from GitLab. |
| 123 | + - :ref:`oauth2_redirect_uri`: Set this to the redirect URI configured in GitLab. |
| 124 | +4. (Optional) To restrict access to specific GitLab groups, you can utilize the `FLOWER_GITLAB_AUTH_ALLOWED_GROUPS` environment variable. Set it to a comma-separated list of allowed groups. You can include subgroups by using the `/` character. For example: `group1,group2/subgroup`. |
| 125 | +5. (Optional) The default minimum required group access level can be adjusted using the `FLOWER_GITLAB_MIN_ACCESS_LEVEL` environment variable. |
| 126 | +6. (Optional) The custom GitHub Domain can be adjusted using the `FLOWER_GITLAB_OAUTH_DOMAIN` environment variable. |
118 | 127 |
|
119 | | -A list of allowed GitLab groups can be specified using the |
120 | | - `FLOWER_GITLAB_AUTH_ALLOWED_GROUPS` environment variable (e.g. ``group1,group2/subgroup``). |
| 128 | +For further details on GitLab OAuth and its implementation, refer to the `Group and project members API`_ documentation. |
| 129 | +It provides comprehensive information and guidelines on working with GitLab's OAuth functionality. |
121 | 130 |
|
122 | | -The default minimum required group access level can be changes by |
123 | | -`FLOWER_GITLAB_MIN_ACCESS_LEVEL` environment variable. |
124 | | -See `Group and project members API`_ for details. |
125 | | - |
126 | | - $ export FLOWER_OAUTH2_KEY=7956724aafbf5e1a93ac |
127 | | - $ export FLOWER_OAUTH2_SECRET=f9155f764b7e466c445931a6e3cc7a42c4ce47be |
128 | | - $ export FLOWER_OAUTH2_REDIRECT_URI=http://localhost:5555/login |
129 | | - $ export FLOWER_GITLAB_AUTH_ALLOWED_GROUPS=group1,group2/subgroup |
130 | | - $ celery flower --auth_provider=flower.views.auth.GitLabLoginHandler --auth=.*@example\.com |
| 131 | +See also `GitLab OAuth2 API`_ documentation for more info. |
131 | 132 |
|
| 133 | +.. _GitLab OAuth documentation: https://docs.gitlab.com/ee/integration/oauth_provider.htm |
132 | 134 | .. _GitLab OAuth2 API: https://docs.gitlab.com/ee/api/oauth2.html |
133 | 135 | .. _Group and project members API: https://docs.gitlab.com/ee/api/members.html |
134 | | - |
135 | | -**NOTE:** If you need a custom GitHub Domain, please export it using environment variable: |
136 | | -`export FLOWER_GITLAB_OAUTH_DOMAIN=gitlab.foobar.com` |
0 commit comments