diff --git a/README.md b/README.md index ab48e57..57560a5 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,22 @@ const { logout, currentProvider } = useOidcAuth() ``` +### User object + +The above composable functions grant access to a user object with the following properties: + +| Name | Type | Description | +|---|---|---|---| +| provider | `string` | Name of provider used to login the current session | +| canRefresh | `boolean` | If the current session exposed a refresh token | +| loggedInAt | `number` | Login timestamp in second precision | +| updatedAt | `number` | Refresh timestamp in second precision | +| expireAt | `number` | Session expiration timestamp in second precision. Either loggedInAt plus session maxAge or exp of access token if available. | +| providerInfo | `Record` | Additional information coming from the providers userinfo endpoint | +| userName | `string` | Coming either from the provider or from the configured mapped claim | +| claims | `Record` | Additional optional claims from the id token, if `optionalClaims` setting is configured. | +| accessToken | `string` | Exposed access token, only existent when `exposeAccessToken` is configured. | + ## Server Utils The following helpers are auto-imported in your `server/` directory. @@ -363,6 +379,7 @@ You can theoretically register a hook that overwrites internal session fields li | validateAccessToken | `boolean` (optional) | `true` | Validate access token. | | validateIdToken | `boolean` (optional) | `true` | Validate id token. | | encodeRedirectUri | `boolean` (optional) | `false` | Encode redirect uri query parameter in authorization request. Only for compatibility with services that don't implement proper parsing of query parameters. | +| exposeAccessToken | `boolean` (optional) | `false` | Expose access token to the client within session object | #### `session` diff --git a/playground/composables/useProviders.ts b/playground/composables/useProviders.ts index 29be9de..9b26767 100644 --- a/playground/composables/useProviders.ts +++ b/playground/composables/useProviders.ts @@ -26,6 +26,12 @@ export const useProviders = (currentProvider: string) => { disabled: Boolean(currentProvider === 'keycloak'), icon: 'i-simple-icons-cncf', }, + { + label: 'Generic OIDC', + name: 'oidc', + disabled: Boolean(currentProvider === 'oidc'), + icon: 'i-simple-icons-openid', + }, ]) return { providers, diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index d0c64eb..288fa05 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -56,7 +56,7 @@ export default defineNuxtConfig({ }, session: { expirationCheck: true, - automaticRefresh: true, + automaticRefresh: false, }, middleware: { globalMiddlewareEnabled: true, diff --git a/playground/pages/index.vue b/playground/pages/index.vue index 1aa1ea9..9fba08d 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -4,7 +4,7 @@ const { providers } = useProviders(currentProvider.value as string)