Authentication
Authentication and authorization in Go Micro
Go Micro provides a pluggable authentication interface that covers JWT tokens, account management, scoped access control, and custom auth providers.
Overview
The auth package in go-micro.dev/v6/auth defines the core interfaces:
Auth— the main authentication interfaceAccount— represents an authenticated entity with scopesToken— a JWT-based access token
Quick Start
import "go-micro.dev/v6/auth"
// Use the default auth implementation
a := auth.DefaultAuth
// Generate a token
tok, err := a.Generate("admin")
if err != nil {
// handle error
}
// Validate a token
account, err := a.Inspect(tok.Token)
if err != nil {
// handle error
}
Next Steps
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.