|
| 1 | +# SSO Guide |
| 2 | + |
| 3 | +## How to configure SSO |
| 4 | + |
| 5 | +SSO require additionaly to configure TLS for application, in that example we will use self-signed certificate, in case of use legal certificates please skip step 1. |
| 6 | + |
| 7 | +### Step 1 |
| 8 | + |
| 9 | +At this step we will generate self-signed PKCS12 keypair. |
| 10 | + |
| 11 | +```bash |
| 12 | +mkdir cert |
| 13 | +keytool -genkeypair -alias ui-for-apache-kafka -keyalg RSA -keysize 2048 \ |
| 14 | + -storetype PKCS12 -keystore cert/ui-for-apache-kafka.p12 -validity 3650 |
| 15 | +``` |
| 16 | + |
| 17 | +### Step 2 |
| 18 | + |
| 19 | +Create new application in any SSO provider, we will continue with [Auth0](https://auth0.com). |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +After that need to provide callback URLs, in our case we will use `https://127.0.0.1:8080/login/oauth2/code/auth0` |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +This is a main parameters required for enabling SSO |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +### Step 3 |
| 32 | + |
| 33 | +To launch UI for Apache Kafka with enabled TLS and SSO run following: |
| 34 | + |
| 35 | +```bash |
| 36 | +docker run -p 8080:8080 -v `pwd`/cert:/opt/cert -e AUTH_TYPE=LOGIN_FORM \ |
| 37 | + -e SECURITY_BASIC_ENABLED=true \ |
| 38 | + -e SERVER_SSL_KEY_STORE_TYPE=PKCS12 \ |
| 39 | + -e SERVER_SSL_KEY_STORE=/opt/cert/ui-for-apache-kafka.p12 \ |
| 40 | + -e SERVER_SSL_KEY_STORE_PASSWORD=123456 \ |
| 41 | + -e SERVER_SSL_KEY_ALIAS=ui-for-apache-kafka \ |
| 42 | + -e SERVER_SSL_ENABLED=true \ |
| 43 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTID=uhvaPKIHU4ZF8Ne4B6PGvF0hWW6OcUSB \ |
| 44 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTSECRET=YXfRjmodifiedTujnkVr7zuW9ECCAK4TcnCio-i \ |
| 45 | + -e SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_AUTH0_ISSUER_URI=https://dev-a63ggcut.auth0.com/ \ |
| 46 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_SCOPE=openid \ |
| 47 | + -e TRUST_STORE=/opt/cert/ui-for-apache-kafka.p12 \ |
| 48 | + -e TRUST_STORE_PASSWORD=123456 \ |
| 49 | +provectuslabs/kafka-ui:latest |
| 50 | +``` |
| 51 | + |
| 52 | +In the case with trusted CA-signed SSL certificate and SSL termination somewhere outside of application we can pass only SSO related environment variables: |
| 53 | + |
| 54 | +```bash |
| 55 | +docker run -p 8080:8080 -v `pwd`/cert:/opt/cert -e AUTH_TYPE=OAUTH2 \ |
| 56 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTID=uhvaPKIHU4ZF8Ne4B6PGvF0hWW6OcUSB \ |
| 57 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTSECRET=YXfRjmodifiedTujnkVr7zuW9ECCAK4TcnCio-i \ |
| 58 | + -e SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_AUTH0_ISSUER_URI=https://dev-a63ggcut.auth0.com/ \ |
| 59 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_SCOPE=openid \ |
| 60 | +provectuslabs/kafka-ui:latest |
| 61 | +``` |
| 62 | + |
| 63 | +### Step 4 (Load Balancer HTTP) (optional) |
| 64 | + |
| 65 | +If you're using load balancer/proxy and use HTTP between the proxy and the app, you might want to set `server_forward-headers-strategy` to `native` as well (`SERVER_FORWARDHEADERSSTRATEGY=native`), for more info refer to [this issue](https://github.com/provectus/kafka-ui/issues/1017). |
| 66 | + |
| 67 | +### Step 5 (Azure) (optional) |
| 68 | + |
| 69 | +For Azure AD (Office365) OAUTH2 you'll want to add additional environment variables: |
| 70 | + |
| 71 | +```bash |
| 72 | +docker run -p 8080:8080 \ |
| 73 | + -e KAFKA_CLUSTERS_0_NAME="${cluster_name}"\ |
| 74 | + -e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS="${kafka_listeners}" \ |
| 75 | + -e KAFKA_CLUSTERS_0_ZOOKEEPER="${zookeeper_servers}" \ |
| 76 | + -e KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS="${kafka_connect_servers}" |
| 77 | + -e AUTH_TYPE=OAUTH2 \ |
| 78 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTID=uhvaPKIHU4ZF8Ne4B6PGvF0hWW6OcUSB \ |
| 79 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_CLIENTSECRET=YXfRjmodifiedTujnkVr7zuW9ECCAK4TcnCio-i \ |
| 80 | + -e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_AUTH0_SCOPE="https://graph.microsoft.com/User.Read" \ |
| 81 | + -e SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_AUTH0_ISSUER_URI="https://login.microsoftonline.com/{tenant-id}/v2.0" \ |
| 82 | + -d provectuslabs/kafka-ui:latest" |
| 83 | +``` |
| 84 | +
|
| 85 | +Note that scope is created by default when Application registration is done in Azure portal. You'll need to update application registration manifest to include `"accessTokenAcceptedVersion": 2` |
0 commit comments