Skip to content
Search Latest (1.4)

Single sign-on

TAK Server 5.7 handles single sign-on (SSO) for users of Team Awareness Kit (TAK) through its own OpenID Connect (OIDC) authorization-code flow, so people sign in to the TAK web user interface (UI) with their Unified Defense Stack (UDS) Keycloak account. The Package registers one Keycloak client. An init container fills the client secret into CoreConfig.xml on every start. Authservice is not in front of TAK.

The Keycloak client:

Field Value
Client name TAK Server Login
Client id uds-takserver
Protocol openid-connect
Public client false
Standard flow true
Full scope false
Default scopes openid, profile, email
Refresh tokens use.refresh.tokens=true
Login gate groups.anyOf /UDS Core/Admin. CloudTAK also allows /CloudTAK/Users. See CloudTAK
Secret takserver-sso, key TAK_OIDC_CLIENT_SECRET
Redirect https://takserver.<domain>/login/redirect
Issuer document https://sso.<domain>/realms/uds/.well-known/openid-configuration
Authservice not used

The sign-in routes: GET /login/auth redirects the browser to Keycloak. GET /login/redirect exchanges the code. GET /login/refresh refreshes the token (com.bbn.marti.oauth.OAuthApi). useTakServerLoginPage is false, so a 401 on the browser connector is sent to /login/auth.

The browser UI is https://takserver.<domain>/ on the tenant gateway, which terminates browser Transport Layer Security (TLS) and opens a new TLS connection to port 8447. The redirect has no port because that host is published on 443. Certificate enrollment stays on 8446. Ports 8443 and 8089 still require a client certificate.

TAK Server metrics dashboard after a Keycloak sign-in

TAK listens on four TLS connectors. Only 8446 and 8447 take a browser sign-in:

Port TLS Client certificate UI
8443 on required unchanged cert-only connector
8446 on, passthrough off admin UI and WebTAK off. Enrollment (/Marti/api/tls/signClient/v2 with a bearer token) and /login/.well-known/openid-configuration
8447 on off admin UI, WebTAK, and the non-admin UI
8089 on required streaming, unchanged

Bearer tokens and the access-token cookie are accepted only when the local port is 8446 or 8447 (AccessTokenResolver). The stock application programming interface (API) Service does not publish 8447. This chart adds Service takserver-web with port name https and appProtocol: https, and DestinationRule takserver-web, so the tenant gateway speaks TLS to the connector. See Networking.

auth stays default="file". X509Authenticator throws if the default is not a supported method, and file is the one certificate login still uses. x509groups and x509tokenAuth are on. There is one discovery entry and no authServer.

<auth default="file" x509groups="true" x509tokenAuth="true">
<File location="/opt/tak/UserAuthenticationFile.xml"/>
<oauth oauthUseGroupCache="false"
useTakServerLoginPage="false"
usernameClaim="preferred_username"
groupsClaim="groups"
groupprefix="/tak/"
groupNameExtractorRegex="^/TAK/(.+)$"
readGroupSuffix="_READ"
writeGroupSuffix="_WRITE"
adminTokenClaimName="groups"
adminTokenClaimValue="/UDS Core/Admin">
<openIdDiscoveryConfiguration name="UDS SSO"
clientId="uds-takserver"
secret="${TAK_OIDC_CLIENT_SECRET}"
redirectUri="https://takserver.uds.dev/login/redirect"
configurationUri="https://sso.uds.dev/realms/uds/.well-known/openid-configuration"
trustAllCerts="false"/>
</oauth>
</auth>

The upstream chart mounts CoreConfig.xml read-only and has no init-container value. The takserver-oidc Pepr module in pepr/ adds an init container to the config, messaging, API, and plugins pods when each pod is created. No pod can start with the unrendered file.

That container runs envsubst '${TAK_OIDC_CLIENT_SECRET}' from Secret takserver-sso into /conf/CoreConfig.xml. TAK prefers conf/CoreConfig.xml over CoreConfig.xml (LocalConfiguration). The config service is what publishes the file to the other processes.

The secret template is only TAK_OIDC_CLIENT_SECRET: clientField(secret). The secret is labeled uds.dev/pod-reload: "true" with selector uds.dev/oidc-reload=takserver, so a rotated secret restarts those pods and the init container reads it again.

trustAllCerts is false. The API and messaging init containers copy the Java virtual machine (JVM) trust store and import ConfigMap uds-trust-bundle when that file has certificates. Slim core does not set the certificate authority (CA) bundle variables, and the operator deletes the ConfigMap when the bundle would be empty. In that case the init container imports the certificate chain presented by the tenant gateway for the discovery host. Public Domain Name System (DNS) for sso.uds.dev is 127.0.0.1, which inside a pod is the pod itself. The package’s in-cluster DNS rewrite answers sso.<domain> with the tenant gateway ClusterIP instead (see Networking).

The gateway certificate fetch has a 15-second deadline and a further 5-second forced-stop grace. Its transcript is limited to 128 KiB. Failed, interrupted or oversized fetches are discarded rather than imported as partial trust sources. An already imported valid UDS bundle remains usable if the gateway fetch fails; when neither source imports a certificate, initialization fails. The deadline command is required whenever a gateway fetch is attempted.

A TAK node that holds the unrendered ${TAK_OIDC_CLIENT_SECRET} placeholder breaks logins for every node. This section explains why, and how the package prevents it.

In upstream 5.7-RELEASE-14, DistributedConfiguration.init() calls loadConfigFromCache() only when cacheConfig is true, then registers an Ignite continuous query either way. registerListener runs that callback immediately. The callback calls setConfiguration and saveChanges, so the cached file replaces the local one. One run saved a 25-character openIdDiscoveryConfiguration secret on the config pod while the cluster secret was 86 characters.

The image build applies .github/container-and-chart/docker/cacheconfig-listener.patch, which registers that listener only when cacheConfig is true. This package sets cacheConfig="false". A save on one node still updates the Ignite cache. It does not rewrite the other nodes’ files. Each pod still renders its own secret before the process starts. The plugins pod used to run without a render step, so it held the placeholder for its whole life.

The takserver-oidc module is a Pepr mutating webhook. Its configuration is pepr/, and pepr/build.sh generates the chart before Zarf creates the package. It acts on pod creation for the four apps that read CoreConfig.xml (takserver-config, takserver-messaging, takserver-api, takserver-plugins) and adds the render-oidc init container, its volumes, the /conf mount, and the pod-reload label. Init containers cannot be added to a running pod, so a pod that has render-oidc has had it since its first start. The chart installs before the upstream chart, so the first pods are admitted through it.

The webhook fails closed and is scoped to the takserver namespace. Within it, the webhook matches those four pods by app label, and it matches the TAK Deployments and Ignite objects by name. If the module is down, only those objects wait. Scoping it matters: a cluster-wide failing webhook blocks the Istio Container Network Interface (CNI) pods the module needs after a node restart. tests/oidc-render.sh checks the webhook, that each pod completed render-oidc, and that each node’s secret matches the cluster secret by length and hash.

OAuthAuthenticator lowercases groupprefix and LdapAuthenticator.applyGroupPrefixFilter lowercases the claim before startsWith, then keeps the original string. Prefix /tak/ therefore matches /TAK/.... GroupNameExtractor compiles the regex CASE_INSENSITIVE, so ^/TAK/(.+)$ does not need a lowercase pattern.

Names that end in _READ or _WRITE set the direction and the suffix is removed, so /TAK/Operators_READ becomes TAK group Operators with direction OUT.

/UDS Core/Admin does not match /tak/. It is only the admin claim (adminTokenClaimName / adminTokenClaimValue), which grants ROLE_ADMIN before the prefix filter. The Package groups.anyOf list is a Keycloak login gate, not the TAK group map. The group-membership mapper puts full paths in the access token and the ID token. claim.name is groups. That mapper is already on the UDS default protocol-mapper allowlist, so SECURITY_HARDENING_ADDITIONAL_PROTOCOL_MAPPERS is left empty.

usernameClaim is preferred_username.

/UDS Core/Admin sends HomeApi to /Marti. The test user is also in /TAK/Operators_READ, and GET /Marti/api/groups/all is what shows that mapped group. There is no route named whoami.

The display names are TAK Server Login and CloudTAK Login. The client ids stay uds-takserver and uds-cloudtak. The template’s uds-<group>-<app> form would be a second client. The pods, CoreConfig, and the CloudTAK sign-in route already use these ids, and an existing cluster already has the clients. Renaming them would leave the old clients in the realm and break the secret the pods mount.

Both clients set client.session.idle.timeout to 600 and client.session.max.lifespan to 36000. UDS Core 1.16.0 imports the uds realm from uds-identity-config 0.32.4. That import uses an idle timeout of 600 seconds and a max lifespan of 36000 when REALM_SSO_SESSION_IDLE_TIMEOUT and REALM_SSO_SESSION_MAX_LIFESPAN are unset, which this bundle leaves unset. Keycloak 26 rejects the client when its idle timeout is longer than the realm’s. An idle timeout of 1800 did that, and the Package stayed InProgress.

/UDS Core/Admin is the Keycloak login gate (groups.anyOf). UDS Core creates that group. /TAK/Operators_READ is not a login gate. TAK maps it to the Operators group. An operator creates that group once and puts users in it.

This package does not add an OpenTofu component for one group the realm gate does not use. tests/ensure-tak-group.py is the continuous integration (CI) fixture that creates it for doug. It is not a Zarf deploy action. tests/ensure-outsider.py creates outsider with no groups, and the Playwright spec expects Keycloak to refuse both clients. tests/ensure-map-user.py creates mapuser in /CloudTAK/Users and /TAK/Operators_READ. The CloudTAK client lets it in, and the TAK client refuses it. tests/sso-clients.py reads the client attributes back from the admin API.

TAK verifies the token’s RS256 signature and nothing else about the token. Plan for these gaps:

  • No issuer check. Discovery stores the signing key and clears issuer. Any token from the uds realm whose signature matches that key is accepted, including a token minted for a different client, as long as the group claims match.
  • No audience check.
  • No Proof Key for Code Exchange (PKCE). The client does not set pkce.code.challenge.method.
  • Logout clears the access-token cookie and redirects inside TAK (AuthCookieUtils.logout). TAK still does not call the Keycloak end-session endpoint. The client registers post.logout.redirect.uris anyway, so a caller that does end the session can return to /login/redirect. CloudTAK’s sign-in route does call end-session. See CloudTAK.
  • One identity provider (IdP). A second openIdDiscoveryConfiguration is not a failover list. TAK picks one entry at random.
  • Port 8089 does not take a browser cookie. With x509tokenAuth, a certificate that was enrolled on 8446 with a bearer token is authenticated as that token’s user.
  • Cookies set on 8447 are marked Secure. AuthCookieUtils uses request.isSecure(), which is true because the gateway reaches 8447 over TLS. With api.web.backendTLS.enabled=false the connector is plaintext and the cookies are not Secure.

Authservice sits on the tenant gateway and authenticates the request before the application sees it. TAK’s login is the authorization-code flow above: the browser must reach /login/auth and /login/redirect, and TAK must set its own access-token cookie. That cookie is only read on local ports 8446 and 8447. Authservice would replace that flow and would not produce the cookie TAK checks.

8443 and 8089 must keep presenting the client certificate to TAK. Passthrough does that. Putting Authservice on those hosts would terminate the connection first and TAK would not see the certificate. The browser UI is the only port moved to the tenant gateway, and it uses TAK’s client rather than Authservice.

API and messaging pods may connect to the tenant gateway:

  • Namespace istio-tenant-gateway
  • Pod labels app=tenant-ingressgateway and istio=tenant-ingressgateway (Istio gateway chart 1.31, release name tenant-ingressgateway)
  • Port 443

That is the path for the discovery document, the token endpoint, and the JSON Web Key Set (JWKS) signing keys. The calls use https://sso.<domain>/.... The in-cluster DNS rewrite sends that name to the gateway ClusterIP.

Messaging needs the same path. With x509tokenAuth, a certificate enrolled on 8446 with a bearer token is stored with that token, and on 8089 TAK authenticates the stream by validating the token against the issuer’s keys. Without the rule and the trust store, TAK logs Remote host terminated the handshake for the discovery document and closes the stream right after TLS. The messaging pod gets the same trust-store init container as the API pod.

There is no rule to Keycloak’s pod on port 8080, and there is no Kubernetes API rule for a render Job. The init container only reads the secret volume.

uds run test-install calls setup:keycloak-user with /UDS Core/Admin, then tests/ensure-tak-group.py adds /TAK/Operators_READ. Playwright opens https://takserver.uds.dev/ on the tenant gateway, expects the Keycloak page, signs in as doug, and lands on /Marti/. TAK has no route named whoami. The test reads Operators from GET /Marti/api/groups/all and ROLE_ADMIN from GET /Marti/api/util/user/roles. GET /Marti/api/util/isAdmin is true for that user.

Enrollment is POST /Marti/api/tls/signClient/v2 on 8446 with the access-token cookie value as a bearer token and no client certificate. CoreConfig certificateSigning uses certs/files/ca-signing.jks, which the cert Job builds from the generated root CA. The certificate signing request (CSR) uses the Keycloak username as its common name. O and OU are TAK and UDS.

The same spec, and tests/smoke.sh, check that 8443 and 8089 reject a handshake with no client certificate. The 8443 Marti check still uses admin.pem. If https://sso.<domain> does not answer, the job skips the account-console setup and the OAuth spec and still runs the certificate checks.

tests/api-smoke.sh is the API smoke test. test:all runs it after install and after upgrade. It checks each port:

  • On 8443 it calls version, groups, contacts, and a mission create, read, and delete with the admin certificate, and the same calls with no certificate must fail.
  • On 8447 it signs in as doug through the authorization-code flow (no extra Keycloak client), then calls version, roles, isAdmin, groups, and security/isSecure, which must return true. The access-token cookies must be Secure. GET /Marti/api/whoami is requested too. TAK 5.7 returns 404 for that path, so the test reads the user’s role and mapped group (ROLE_ADMIN and Operators) from the roles and groups calls instead. A missing token must be 401 or a redirect. A token with a damaged signature must be 401.
  • On 8446 the bearer token enrolls a certificate and the OIDC document must name the Keycloak endpoints.
  • On 8089 that certificate must open a stream that is still up after 8 seconds, and a client with no certificate must be rejected.