Auth providers handle user authentication and access control for Studio. They determine who can log in and edit content.
| Feature | GitHub OAuth | GitLab OAuth | Google OAuth | Custom Auth |
|---|---|---|---|---|
| Authentication | ✅ | ✅ | ✅ | ✅ |
| Git Operations | ✅ Automatic (OAuth token) | ✅ Automatic (OAuth token) | ⚠️ Requires PAT | ⚠️ Requires PAT |
| Access Control | ✅ OAuth scope | ✅ OAuth scope | ⚠️ Moderator whitelist | ⚠️ Custom logic |
| Secured Auth Flow | ✅ Provider-managed | ✅ Provider-managed | ✅ Provider-managed | ⚠️ Self-managed |
GitHub OAuth provides authentication with automatic Git access. Users who authenticate via GitHub can immediately push changes to the repository.
Go to GitHub Developer Settings and click New OAuth App
Fill in the required fields:
https://yourdomain.comhttps://yourdomain.com/__nuxt_studio/auth/githubhttp://localhost:3000/__nuxt_studio/auth/githubAfter creating the OAuth app, you'll receive:
Add the GitHub OAuth credentials to your deployment platform's environment variables or .env file:
STUDIO_GITHUB_CLIENT_ID=<your_github_client_id>
STUDIO_GITHUB_CLIENT_SECRET=<your_github_client_secret>
# Optional: Restrict access to specific users
# STUDIO_GITHUB_MODERATORS=admin@example.com,editor@example.com
GitLab OAuth provides authentication with automatic Git access. Users who authenticate via GitLab can immediately push changes to the repository.
Go to your GitLab User Settings → Applications (or your group/organization settings) and create a New Application.
Fill in the required fields:
https://yourdomain.com/__nuxt_studio/auth/gitlabapi (required for publication)http://localhost:3000/__nuxt_studio/auth/gitlabAfter creating the OAuth application, you'll receive:
Add the GitLab OAuth credentials to your deployment platform's environment variables or .env file:
STUDIO_GITLAB_APPLICATION_ID=<your_gitlab_application_id>
STUDIO_GITLAB_CLIENT_SECRET=<your_gitlab_secret>
# Optional: Restrict access to specific users
# STUDIO_GITLAB_MODERATORS=admin@example.com,editor@example.com
Google OAuth is ideal for non-technical users who don't have GitHub or GitLab accounts.
Go to Google Cloud Console and select or create a project, then navigate to APIs & Services → Credentials.
Click Create Credentials and OAuth client ID and select Web application as the application type.
Fill in the required fields:
https://yourdomain.com/__nuxt_studio/auth/googlehttp://localhost:3000/__nuxt_studio/auth/googleAfter creating the OAuth client, you'll receive:
Since Google doesn't provide Git access, you must also configure a Personal Access Token for repository operations.
Add the Google OAuth credentials, your personal access token and moderator list:
STUDIO_GOOGLE_CLIENT_ID=<your_google_client_id>
STUDIO_GOOGLE_CLIENT_SECRET=<your_google_client_secret>
STUDIO_GITHUB_TOKEN=<your_github_personal_access_token>
STUDIO_GOOGLE_MODERATORS=admin@example.com,editor@example.com
STUDIO_GOOGLE_CLIENT_ID=<your_google_client_id>
STUDIO_GOOGLE_CLIENT_SECRET=<your_google_client_secret>
STUDIO_GITLAB_TOKEN=<your_gitlab_personal_access_token>
STUDIO_GOOGLE_MODERATORS=admin@example.com,editor@example.com
STUDIO_GOOGLE_MODERATORS environment variable is required for Google OAuth. Only users with email addresses in this list can access Studio.For complete control over authentication, you can implement your own auth logic (password forms, SSO, LDAP, etc.) using Studio's session utilities.
You must configure a Personal Access Token for repository operations based on the Git provider you are using.
# For GitHub repositories
STUDIO_GITHUB_TOKEN=<your_github_personal_access_token>
# For GitLab repositories
STUDIO_GITLAB_TOKEN=<your_gitlab_personal_access_token>
See Git Providers for instructions on creating a PAT.
setStudioUserSession(event, user) with a StudioUserSession objectclearStudioUserSession(event) to clear the sessionWhen calling setStudioUserSession, you must provide:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Display name for the user |
email | string | ✅ | User's email address |
providerId | string | ❌ | Unique identifier for the user |
avatar | string | ❌ | URL to user's avatar image |
import { eventHandler, readBody, createError } from 'h3'
import { setStudioUserSession } from '#imports'
export default eventHandler(async (event) => {
const { email, password } = await readBody<{ email?: string, password?: string }>(event)
// ⚠️️ Implement your own secure validation logic here
// This is a simplified example - use proper password hashing and validation
const user = await validateCredentials(email, password)
if (!user) {
throw createError({
statusCode: 401,
message: 'Invalid credentials'
})
}
await setStudioUserSession(event, {
providerId: user.id,
name: user.name,
email: user.email,
avatar: user.avatar || ''
})
return { ok: true }
})
import { eventHandler } from 'h3'
import { clearStudioUserSession } from '#imports'
export default eventHandler(async (event) => {
await clearStudioUserSession(event)
return { ok: true }
})
After successfully setting the session, redirect users to your app root (/). Studio will automatically detect the session and activate for that user.
// After setStudioUserSession...
return sendRedirect(event, '/')
You can restrict access to Studio by defining a whitelist of authorized users through the STUDIO_{PROVIDER}_MODERATORS environment variable.
# GitHub OAuth moderators
STUDIO_GITHUB_MODERATORS=admin@example.com,editor@example.com
# GitLab OAuth moderators
STUDIO_GITLAB_MODERATORS=admin@example.com,editor@example.com
# Google OAuth moderators (required)
STUDIO_GOOGLE_MODERATORS=admin@example.com,editor@example.com
The moderator list is a comma-separated list of email addresses. Only users with matching email addresses will be granted access.
| Provider | Moderator List | Behavior |
|---|---|---|
| GitHub OAuth | Optional | If empty, all OAuth-authenticated users have access |
| GitLab OAuth | Optional | If empty, all OAuth-authenticated users have access |
| Google OAuth | Required | Without moderators, no one can access Studio |
| Custom Auth | N/A | Implement your own access control logic |
By default, Studio uses your deployment URL for OAuth callbacks. To customize the redirect URL:
# GitHub OAuth
STUDIO_GITHUB_REDIRECT_URL=https://custom-domain.com/__nuxt_studio/auth/github
# GitLab OAuth
STUDIO_GITLAB_REDIRECT_URL=https://custom-domain.com/__nuxt_studio/auth/gitlab
# Google OAuth
STUDIO_GOOGLE_REDIRECT_URL=https://custom-domain.com/__nuxt_studio/auth/google
/_studio (or your configured route) to start editing and publishing content.