Configure built-in SSO in a distributed environment

In a distributed environment, unless an edge server forwards logins to the commit server, each server that users log in to requires its own P4 Web Server, and the web server handles the browser part of the login on that server only. To learn about forwarded logins, see Configure built-in SSO in a distributed environment. Give each edge server its own Keycloak client and its own built-in SSO configuration, and then start a P4 Web Server on the edge server.

Built-in SSO supports commit servers and edge servers. Built-in SSO doesn't support forwarding replicas, P4 Proxy, or P4 Broker.

The first built-in SSO login of a user links the Keycloak user to the P4 Server user. The commit server makes the link. Edge servers don't. When a user logs in for the first time on an edge server, the edge server asks the commit server to make the link. After the first login, the user can log in on any server.

The commit server must be reachable for the first login of each user. If an edge server can't reach the commit server, the edge server refuses the first login. Users who have already logged in can still log in on the edge server.

Configure each edge server

All servers must use the same value for the auth.idp.issuer_url and auth.idp.audience configurables. Set auth.idp.client_id, auth.idp.client_secret, and auth.idp.web_uri for each server. Use an edge server with the server ID edge-1 and the web server address https://edge-1.example.com:8443 as an example.

To configure the edge server, follow these steps:

  1. In Keycloak, create a client for the edge server, for example p4server-edge-1. To learn how, see Configure Keycloak for built-in SSO.

  2. In the client, register the redirect URI of the edge server, which is the web server address of the edge server with the verify path. For example, https://edge-1.example.com:8443/auth/verify.

  3. In the environment of the p4d service account of the edge server, set the client secret of the new client. Use a different secret for each client. Don't copy client secrets between servers. To learn how, see Configure P4 Server for built-in SSO.

  4. To set the configurables for the edge server, run the following commands. Prefix each configurable with the server ID of the edge server, and replace the example values with your own.

    p4 configure set edge-1#auth.idp.client_id=p4server-edge-1
    p4 configure set edge-1#auth.idp.client_secret=EDGE1_OIDC_CLIENT_SECRET
    p4 configure set edge-1#auth.idp.auth_method=client_secret_post
    p4 configure set edge-1#auth.idp.web_uri=https://edge-1.example.com:8443

    The auth.idp.client_secret configurable holds the name of the environment variable, not the secret.

  5. To start the P4 Web Server automatically each time the edge server starts, run the following command.

    p4 configure set "edge-1#startup.1=webserver start -p 8443 --services=idp"

    To learn about the command, see Configure P4 Server for built-in SSO.

Repeat these steps for each server that users log in to.

Log in to all servers

The p4 login -a command on an edge server can open the browser twice, one time for each server that issues a ticket. Complete both browser logins. If you complete only the first, the command times out.

Forward logins to the commit server

If the rpl.forward.login configurable is set to 1 on an edge server, the edge server forwards the login of each built-in SSO user to the commit server. The browser part of the login uses the P4 Web Server of the commit server, at the address in the auth.idp.web_uri configurable of the commit server. The commit server stores the session of the user, and the edge server doesn't.

After the login, users can run commands on the edge server, including commands that the edge server forwards to the commit server. For each command of a built-in SSO user, the edge server checks the session with the commit server. This check has the following effects:

  • The commit server must be reachable for every command. If the edge server can't reach the commit server, commands of built-in SSO users fail on the edge server.
  • The commit server refreshes the access token of the user when the token expires, so users don't have to log in again.
  • When the session ends on the commit server, the edge server also refuses commands from the user. For example, the session ends when the user runs p4 logout -a on the commit server.

Next steps

If a login on an edge server fails, see Troubleshoot built-in SSO.