You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When self-hosting a Nuxt application with Docker, it would be valuable to enable/disable OAuth providers without rebuilding the image, simply by providing/removing environment variables in docker-compose.yml.
Feature Request
Would it be possible to make OAuth providers configuration truly dynamic?
The goal would be to:
Enable/disable OAuth providers by simply adding/removing environment variables in .env or docker-compose.yml
No need to rebuild the Docker image when changing OAuth configuration
OAuth buttons and routes would appear/disappear based on the presence of required environment variables
This would greatly improve flexibility for self-hosted deployments, allowing users to configure their authentication methods through environment variables alone.
Example use case:
# Enable only GitHub OAuthservices:
app:
environment:
- NUXT_OAUTH_GITHUB_CLIENT_ID=xxx
- NUXT_OAUTH_GITHUB_CLIENT_SECRET=xxx# Later, enable Google OAuth by just adding variablesservices:
app:
environment:
- NUXT_OAUTH_GITHUB_CLIENT_ID=xxx
- NUXT_OAUTH_GITHUB_CLIENT_SECRET=xxx
- NUXT_OAUTH_GOOGLE_CLIENT_ID=xxx
- NUXT_OAUTH_GOOGLE_CLIENT_SECRET=xxx
The text was updated successfully, but these errors were encountered:
As the server helpers are tree-shakable for maximum performance and minimum server bundle size, you will have to import then and create your own dynamic provider server endpoint.
Please see an example on how to achieve this by creating a /auth/:provider endpoint:
// server/routes/auth/[provider].get.tsimport{z}from'zod'import{defineOAuthGitHubEventHandler,defineOAuthGoogleEventHandler}from'#imports'constoAuthEventHandlers={github: defineOAuthGitHubEventHandler,google: defineOAuthGoogleEventHandler}exportdefaultdefineEventHandler(async(event)=>{// Validate the providerconst{ provider }=awaitgetValidatedRouterParams(event,z.object({provider: z.enum(['github','google'])}).parse)// Make sure the provider client id and secret are setconstproviderConfig=useRuntimeConfig(event).oauth[provider]if(!providerConfig.clientId||!providerConfig.clientSecret){throwcreateError({statusCode: 400,statusMessage: `OAuth ${provider} is not configured`})}returnoAuthEventHandlers[provider]({config: {// extra config for the provider},onSuccess(event,{ user, tokens }){// You code to handle for providers},onError(event,error){// You code to handle for providers}})(event)})
Context
When self-hosting a Nuxt application with Docker, it would be valuable to enable/disable OAuth providers without rebuilding the image, simply by providing/removing environment variables in docker-compose.yml.
Feature Request
Would it be possible to make OAuth providers configuration truly dynamic?
The goal would be to:
This would greatly improve flexibility for self-hosted deployments, allowing users to configure their authentication methods through environment variables alone.
Example use case:
The text was updated successfully, but these errors were encountered: