Configure Google OAuth2 Authentication
To enable Google OAuth2, you must register a new application with Google.
Create Google OAuth2 Keys
In the Google environment, follow these steps:
-
Navigate to the Google Credentials page.
-
Click Create credentials > OAuth client ID.
-
Select the Web application type.
-
Enter Name , such as Kloudfuse.
-
Enter URL of the kloudfuse installation in the Authorized JavaScript Origins.
Example:
kloudfuse.yourcompany.com -
Enter URL that has the
/oauth2/callbackof the kloudfuse in the Authorized redirect URIs.Example:
kloudfuse.yourcompany.com/oauth2/callback -
Click Create.
-
Copy the Client ID and Client Secret from the
OAuth Clientmodal.Save it for next steps.
Enable Google Auth in Kloudfuse
Option 1: Use Client ID and Secret
In your custom-values.yaml file, add google client ID and secret:
kfuse-auth:
oauth2-proxy:
config:
clientID: "REPLACE_CLIENT_ID"
clientSecret: "REPLACE_CLIENT_SECRET"
Option 2: Use Kubernetes secrets
In the kfuse namespace, create 2 kubernetes secrets:
-
Create a secret called
kfuse-auth-usersas mentioned here. -
Create a new kubernetes secret,
kfuse-auth-users; you can also update an existing secret.Use the output of
cat users.txt| base64as the value ofusers.txtentry in the secret.Use the
editcommand if editing an existing secret.
kubectl edit secret kfuse-auth-users
apiVersion: v1
data:
users.txt: |-
<base64-encoded-value-from-above>
kind: Secret
metadata:
name: kfuse-auth-users
type: Opaque
-
Create a new kubernetes secret,
kfuse-auth-google.Use base64-encoded values for client id and client secret from
kfuse-auth-userssecret.To generate cookie secret, see the OAuth2 Proxy documentation for Generating a Cookie Secret.
Create kubernetes secret kfuse-auth-googleapiVersion: v1 data: client-id: <base 64 encoded google client id> client-secret: <base 64 encoded google client secret> cookie-secret: <base 64 encoded random value> kind: Secret metadata: name: kfuse-auth-google type: Opaqueyaml -
Include the two secrets in your
custom-values.yamlfile:Add secrets tocustom-values.yamlkfuse-auth: oauth2-proxy: config: existingSecret: "kfuse-auth-google" htpasswdFile: existingSecret: "kfuse-auth-users"yaml
Configure Cookies
For some applications that must adhere to external compliance requirements, you may have to use custom configuration for cookies.
| Cookie refresh functionality described in this section only works with OIDC-based authentication (such as Google OAuth2). It is not compatible with SAML-based authentication setups. |
If after applying the cookie configuration settings you are not seeing the expected refresh behavior, try adding offline_access to the OAuth2 scope. This scope allows the system to obtain refresh tokens from the identity provider. Note that some providers (like Google) do not require this scope, while others may need it. For Okta configuration with offline_access, see Add offline_access Scope.
|
Concepts
- cookie-expire
-
Total lifetime of the session cookie. It the user shows no activity after this duration, the system logs the user out. The user must subsequently re-authenticate.
- cookie-refresh
-
Interval at which OAuth2-Proxy automatically uses the IdP refresh token to renew the session cookie, and resets its TTL. This gets triggered by an active HTTP request, such as a click, navigation, or AJAX.
- Activity
-
Any HTTP request sent to the protected App — page navigation, AJAX call, or link click. Passive actions like hovering or viewing the page qualify as
InactivityorIdletime. - Behavior
-
On each valid request, if the session cookie is older than
cookie-refresh, OAuth2-Proxy calls the IdP to get a fresh access token, and the re-issuess the cookie with a fullcookie-expireTTL. If no requests occur within thecookie-expirewindow, the session expires.
Idle Timeout/Inactivity Configuration for Kloudfuse OAuth2-Proxy
For example, to meet HIPPA standards, you must configure the cookie-expiry and cookie-refresh parameters for logout and other workflows.
To control automatic logout after a period of user inactivity, or idle timeout, tune the cookie-expire and cookie-refresh settings in your custom YAML.
To set the idle timeout, follow these steps:
-
Choose the idle timeout period. This is the
cookie-expirevalue. -
Set the refresh interval to a value shorter than the
cookie-expireyou chose in the previous step. This becomes yourcookie-refreshvalue.
To log users out after 30 minutes of inactivity, and to renew their session every 5 minutes when active, add the following code to your custom yaml file:
kfuse-auth:
oauth2-proxy:
extraArgs:
cookie-expire: "30m" (1)
cookie-refresh: "5m" (2)
| 1 | cookie-expire: "30m" means that the session lasts up to 30 minutes without activity. |
| 2 | cookie-refresh: "5m" means that for each request older than 5 minutes, OAuth2-Proxy will renew the cookie. |
|