|
5 | 5 | --- |
6 | 6 |
|
7 | 7 | (how-to-spark-history-server-auth)= |
8 | | -# Enable authorization and authentication with the Spark History Server charm |
| 8 | +# Enable authentication and authorization with the Spark History Server charm |
9 | 9 |
|
10 | | -The Charmed Apache Spark solution includes the Spark History charm that enables users to monitor |
11 | | -their applications workflows and logs. Natively, this product does not support authentication and |
12 | | -authorization that is an essential feature in a production environment. To overcome this limitation, |
13 | | -the Spark History Server charm is integrated with the Canonical Identity bundle that offers several |
14 | | -authentication and authorization functionalities with Juju. |
| 10 | +Charmed Apache Spark includes the Spark History Server charm, which lets users monitor |
| 11 | +application workflows and logs. By default, Spark History Server does not provide |
| 12 | +authentication or authorization, both of which are essential in production environments. |
| 13 | +To address this limitation, you can integrate the Spark History Server charm with the |
| 14 | +Canonical Identity Platform bundle. |
15 | 15 |
|
16 | 16 | ## Deploy the Identity Bundle and integrate it with the Spark History Server |
17 | 17 |
|
18 | | -In order to enable authentication and authorization on the Spark History Server charm some steps |
19 | | -are needed. Here, we assume that you have already deployed Charmed Apache Spark using |
20 | | -the bundles, as described in the [Charmed Apache Spark deployment guide](how-to-deploy-spark), |
21 | | -that includes a Spark History Server charm, already configured with an object storage backend. |
| 18 | +To enable authentication and authorization for Spark History Server, complete the |
| 19 | +following steps. This guide assumes you already deployed Charmed Apache Spark as |
| 20 | +described in the [Charmed Apache Spark deployment guide](how-to-deploy-spark), |
| 21 | +including a Spark History Server charm configured with an object storage backend. |
22 | 22 |
|
23 | | -In order to enable authentication, we first need to deploy the |
24 | | -[identity bundle](https://discourse.charmhub.io/t/iam-bundle-deployment-tutorial/11916). |
| 23 | +### Deploy the Identity bundle |
25 | 24 |
|
26 | | -**_NOTE:_** Please take a look at the Identity Platform tutorial to check that your environment is configured correctly. |
| 25 | +Authentication is provided by the |
| 26 | +[Canonical Identity Bundle](https://charmhub.io/topics/canonical-identity-platform). |
| 27 | +Deploy it by following this |
| 28 | +[tutorial](https://charmhub.io/topics/canonical-identity-platform/tutorials/e2e-tutorial), |
| 29 | +which installs all required Identity Platform components. |
27 | 30 |
|
28 | | -```bash |
29 | | -juju deploy identity-platform --channel edge --trust |
30 | | -``` |
| 31 | +The deployment includes these charms: |
31 | 32 |
|
32 | | -After some minutes the different charms will be deployed and ready to use. |
| 33 | +- [Charmed Ory Hydra](https://charmhub.io/hydra): the OAuth/OIDC server. |
| 34 | +- [Charmed Ory Kratos](https://charmhub.io/kratos): user management and authentication. |
| 35 | +- [Login UI operator](https://charmhub.io/identity-platform-login-ui-operator): middleware that routes requests between services and serves login/error pages. |
| 36 | +- [Kratos External IdP Integrator](https://charmhub.io/kratos-external-idp-integrator): integration with external identity providers. |
| 37 | +- [Charmed PostgreSQL](https://charmhub.io/postgresql-k8s): SQL database backend. |
| 38 | +- [Charmed Traefik](https://charmhub.io/traefik-k8s): ingress controller. |
| 39 | +- [Self Signed Certificates](https://charmhub.io/self-signed-certificates): TLS certificate provider for ingress. |
33 | 40 |
|
34 | | -One needed step to properly configure the Identity Bundle is to configure which identity provider we |
35 | | -want to use. This can be done by configuring the `kratos-external-idp-integrator` with the |
36 | | -configurations and parameters of your identity provider. |
| 41 | +You must also configure the identity provider you want to use. Configure |
| 42 | +`kratos-external-idp-integrator` with the parameters for your provider. |
37 | 43 |
|
38 | | -The following is an example of configuration for the Azure Identity provider: |
| 44 | +Example configuration for Microsoft Entra ID (Azure AD): |
39 | 45 |
|
40 | 46 | ```bash |
41 | | -juju config kratos-external-idp-integrator microsoft_tenant_id=<YOUR_TENANT_ID> provider=microsoft client_id=<YOUR_CLIENT_ID> client_secret=<YOUR_CLIENT_SECRETS>. |
| 47 | +juju config kratos-external-idp-integrator microsoft_tenant_id=<YOUR_TENANT_ID> provider=microsoft client_id=<YOUR_CLIENT_ID> client_secret=<YOUR_CLIENT_SECRET> |
42 | 48 | ``` |
43 | 49 |
|
44 | | -More information about supported identity providers and other useful information can be found in the |
| 50 | +For supported identity providers and additional details, see the |
45 | 51 | [How to manage external identity providers guide](https://discourse.charmhub.io/t/how-to-manage-external-identity-providers/11910). |
46 | 52 |
|
47 | | -The relation between the Spark History Server and the Identity bundle is handled by another charm |
48 | | -(Oathkeeper) that is offered by the Canonical Identity Team. |
49 | | -This charm enables the protection of endpoints that are behind an ingress, more specifically Traefik. |
50 | | -As the next step, we need to integrate the Spark History Server charm with Traefik. |
| 53 | +The connection between Spark History Server and the Identity Platform is handled by |
| 54 | +the Charmed OAuth2 Proxy charm. OAuth2 Proxy protects endpoints exposed through |
| 55 | +ingress (Traefik). |
| 56 | + |
| 57 | +## Enable authentication with Charmed OAuth2 Proxy |
51 | 58 |
|
52 | | -The Identity bundle deployed two instances of Traefik, we will need to use the one named: `traefik-public` |
| 59 | +To set up OAuth2 Proxy, first enable the feature in Traefik, expose the forward-auth |
| 60 | +offer, and integrate it with Spark History Server through the ingress relation. |
53 | 61 |
|
54 | 62 | ```bash |
55 | | -juju integrate spark-history-server-k8s traefik-public |
| 63 | +juju config traefik-public enable_experimental_forward_auth=True -m <IDENTITY_MODEL> |
| 64 | +juju offer traefik-public:experimental-forward-auth forward-auth -m <IDENTITY_MODEL> |
| 65 | +juju integrate spark-history-server-k8s admin/<IDENTITY_MODEL>.ingress |
| 66 | +``` |
| 67 | + |
| 68 | +Next, deploy OAuth2 Proxy and integrate it with Traefik using the exposed offer: |
56 | 69 |
|
| 70 | +```bash |
| 71 | +juju deploy oauth2-proxy-k8s --channel latest/stable --trust |
| 72 | +juju integrate oauth2-proxy-k8s:forward-auth admin/<IDENTITY_MODEL>.forward-auth |
57 | 73 | ``` |
58 | 74 |
|
59 | | -After it, we can deploy, configure and integrate the Oathkeeper charm with `traefik-public`. |
| 75 | +Then integrate Spark History Server with OAuth2 Proxy: |
60 | 76 |
|
61 | 77 | ```bash |
62 | | -juju deploy oathkeeper --channel edge --trust |
63 | | -juju config oathkeeper dev=True |
64 | | -juju config traefik-public enable_experimental_forward_auth=True |
| 78 | +juju integrate oauth2-proxy-k8s spark-history-server-k8s:oauth2-proxy |
65 | 79 | ``` |
66 | 80 |
|
67 | | -Now we need to integrate Oathkeeper with the ingress and with the Spark History Server charm. |
68 | | -The Oathkeeper charm will also need to be integrated with the Kratos charm. |
| 81 | +Finally, integrate OAuth2 Proxy with the Identity Platform OIDC provider |
| 82 | +(Charmed Hydra): |
69 | 83 |
|
70 | 84 | ```bash |
71 | | -juju integrate oathkeeper spark-history-server-k8s |
72 | | -juju integrate oathkeeper traefik-public:experimental-forward-auth |
73 | | -juju config kratos dev=true |
74 | | -juju integrate oathkeeper kratos |
| 85 | +juju offer hydra:oauth oauth -m <IDENTITY_MODEL> |
| 86 | +juju integrate oauth2-proxy-k8s:oauth admin/<IDENTITY_MODEL>.oauth |
75 | 87 | ``` |
76 | 88 |
|
77 | | -Eventually, you can get the endpoint by running this action: |
| 89 | +After integration completes, get the endpoint by running: |
78 | 90 |
|
79 | 91 | ```bash |
80 | | -juju run traefik-public/0 show-proxied-endpoints |
| 92 | +juju run traefik-public/leader show-proxied-endpoints -m <IDENTITY_MODEL> |
81 | 93 | ``` |
82 | 94 |
|
83 | | -When you access the link exposed by Traefik, you will be redirected to your desired |
84 | | -identity provider to do the authentication. After a successful authentication, |
85 | | -you will be permitted to access the Spark History server endpoint. |
| 95 | +When you open the URL exposed by Traefik, you are redirected to your configured |
| 96 | +identity provider for authentication. After successful login, you can access the |
| 97 | +Spark History Server endpoint. |
86 | 98 |
|
87 | 99 | ## Authorization Management |
88 | 100 |
|
89 | | -By default, all authenticated users can access the Spark History Server endpoint. To limit access to a selected set of users, the Spark History Server charm offers the possibility to specify authorized users. This can be done by updating a configuration option. The authorized users (identified by email address) should be specified as a comma-separated list. |
| 101 | +By default, all authenticated users can access Spark History Server. To restrict |
| 102 | +access, configure an allow-list of authorized users. Provide email addresses as a |
| 103 | +comma-separated list: |
90 | 104 |
|
91 | 105 | ```bash |
92 | | -juju config spark-history-server-k8s authorized-users="user1@canonical.com, user3@canonical.com" |
| 106 | +juju config spark-history-server-k8s authorized-users="user1@canonical.com,user3@canonical.com" |
93 | 107 | ``` |
| 108 | + |
| 109 | +## Oathkeeper integration (deprecated) |
| 110 | + |
| 111 | +Previously, authentication in this guide used the `oathkeeper` charm. `oathkeeper` |
| 112 | +is now deprecated in favor of Charmed OAuth2 Proxy. |
| 113 | + |
| 114 | +If your deployment still uses `oathkeeper`, migrate by removing integrations with |
| 115 | +`oathkeeper`, updating Identity Platform components as described above, and then |
| 116 | +integrating `oauth2-proxy-k8s`. |
0 commit comments