Configuring access and identity token validity
Change the default setting of the access token and identity token validity.
By default, the access token and identity (ID) token are valid for 12 hours after you sign out of the management console or close your browser. You can change this default value as required.
Follow these steps to change the token validity:
- Set up the
kubectlCLI. See Accessing your cluster from the Kubernetes CLI (kubectl). -
Edit the
platform-auth-idpconfigmap.kubectl -n kube-system edit configmap platform-auth-idpThe file content resembles the following code:
# Please edit the following object. Lines beginning with a '#' will be ignored, # and an empty file will abort the edit. If an error occurs while saving this file will be # reopened with the relevant failures. # apiVersion: v1 data: AUDIT_ENABLED_IDMGMT: "false" AUDIT_ENABLED_IDPROVIDER: "false" BASE_AUTH_URL: /v1 BASE_OIDC_URL: https://127.0.0.1:8443/idauth/oidc/endpoint/OP CLUSTER_NAME: mycluster HTTP_ONLY: "true" IDENTITY_AUTH_DIRECTORY_URL: http://127.0.0.1:3100 IDENTITY_PROVIDER_URL: http://127.0.0.1:4300 IDTOKEN_LIFETIME: 12h JOURNAL_PATH: /run/systemd/journal MASTER_HOST: mycluster.icp NODE_ENV: production OAUTH2DB_DB_HOST: mongodb OAUTH2DB_DB_PORT: "3306" OIDC_ISSUER_URL: https://mycluster.icp:8443/oidc/endpoint/OP SESSION_TIMEOUT: "43200" logrotate: |- /var/log/audit/*.log { su nobody root . . . -
Update the values of the
SESSION_TIMEOUTandIDTOKEN_LIFETIMEparameters. TheSESSION_TIMEOUTparameter sets the access token validity, the default value of which is43200seconds. TheIDTOKEN_LIFETIMEparameter sets the ID token validity, the default value of which is12hours. Specify a positive integer followed by a unit of time, which can be hours (h), minutes (m), or seconds (s). For example, specify 30 seconds as 30s. You can include multiple values in a single entry. For example, 1m30s is equivalent to 90 seconds.After you update and save the changes, you see the following message:
configmap "platform-auth-idp" edited -
Restart the
auth-idppod.a. Get the
auth-idppod ID.kubectl -n kube-system get pods | grep auth-idpFollowing is a sample output of the command:
auth-idp-t6sfm 4/4 Running 0 1db. Delete the
auth-idppod.kubectl -n kube-system delete pod auth-idp-t6sfmAfter the pod is deleted, you see the following message:
pod "auth-idp-t6sfm" deletedWait for a few minutes for the pod to restart.
c. Verify the status of the pod.
kubectl -n kube-system get pods | grep auth-idp-t6sfmThe pod gets a new ID after restart.
auth-idp-5267t 1/4 Running 0 4m