Skip to main content
The feathers generate authentication command sets up authentication in your application. This includes creating a user service, configuring authentication strategies, and setting up OAuth providers if needed.

Usage

Alias: feathers g authentication

Interactive Prompts

When you run this command, you’ll be prompted for:

Authentication Strategies

string[]
required
The authentication methods to enable in your applicationChoices (multiple selection):
  • local - Email + Password (checked by default)
  • google - Google OAuth
  • facebook - Facebook OAuth
  • twitter - Twitter OAuth
  • github - GitHub OAuth
  • auth0 - Auth0 OAuth
You can select multiple strategies. Additional providers can be added later.

User Service Configuration

If you select local (Email + Password) authentication:
string
The name for the user serviceDefault: users
string
The API path for the user serviceDefault: Same as service name (e.g., /users)
string
Schema validation libraryChoices:
  • typebox - TypeBox (recommended)
  • json - JSON Schema

What Gets Generated

Running this command will:
1

Install authentication packages

Installs required authentication packages:
For OAuth strategies, also installs:
2

Create user service

Generates a complete user service with:
  • Service class (src/services/users/users.class.ts)
  • Schema definitions with password hashing (src/services/users/users.schema.ts)
  • Service registration (src/services/users/users.ts)
  • Shared types (src/services/users/users.shared.ts)
3

Configure authentication

Creates src/authentication.ts with:
  • JWT strategy configuration
  • Local strategy setup (if selected)
  • OAuth strategy setup (if selected)
4

Update configuration files

Adds authentication configuration to:
  • config/default.json - JWT secret, authentication settings
  • config/production.json - Production-specific settings
For OAuth strategies, adds provider client IDs and secrets.
5

Register authentication

Updates src/app.ts to configure authentication services and hooks
6

Update client types

Updates src/client.ts with authentication client configuration

Generated Files Example

User Service Schema

src/services/users/users.schema.ts

Authentication Configuration

src/authentication.ts

Configuration

config/default.json

OAuth Setup

If you selected OAuth providers, you’ll need to:
1

Create OAuth application

Register your application with the OAuth provider (Google, GitHub, etc.) to get client credentials
2

Configure redirect URLs

Set the OAuth callback URL to: http://localhost:3030/oauth/{provider}/callbackFor production, use your actual domain.
3

Add credentials to configuration

Update config/default.json with your OAuth client ID and secret:
4

Use environment variables in production

config/production.json
Never commit OAuth secrets to version control. Always use environment variables for sensitive credentials.

Testing Authentication

After generation, you can test authentication:

Next Steps

Authentication Guide

Learn how to use authentication in your app

JWT Configuration

Configure JWT tokens and strategies

OAuth Setup

Set up OAuth providers

Local Strategy

Configure email/password authentication