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
feathers g authentication
Interactive Prompts
When you run this command, you’ll be prompted for:Authentication Strategies
The authentication methods to enable in your applicationChoices (multiple selection):
local- Email + Password (checked by default)google- Google OAuthfacebook- Facebook OAuthtwitter- Twitter OAuthgithub- GitHub OAuthauth0- Auth0 OAuth
User Service Configuration
If you select local (Email + Password) authentication:The name for the user serviceDefault:
usersThe API path for the user serviceDefault: Same as service name (e.g.,
/users)Schema validation libraryChoices:
typebox- TypeBox (recommended)json- JSON Schema
What Gets Generated
Running this command will:Install authentication packages
Installs required authentication packages:For OAuth strategies, also installs:
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)
Configure authentication
Creates
src/authentication.ts with:- JWT strategy configuration
- Local strategy setup (if selected)
- OAuth strategy setup (if selected)
Update configuration files
Adds authentication configuration to:
config/default.json- JWT secret, authentication settingsconfig/production.json- Production-specific settings
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:Create OAuth application
Register your application with the OAuth provider (Google, GitHub, etc.) to get client credentials
Configure redirect URLs
Set the OAuth callback URL to:
http://localhost:3030/oauth/{provider}/callbackFor production, use your actual domain.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