mirror of
https://github.com/h44z/wg-portal.git
synced 2025-04-19 08:55:12 +00:00
32 lines
659 B
Go
32 lines
659 B
Go
package authentication
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type AuthContext struct {
|
|
Provider AuthProvider
|
|
Username string // email or username
|
|
Password string // optional for OIDC
|
|
Callback string // callback for OIDC
|
|
}
|
|
|
|
type AuthProviderType string
|
|
|
|
const (
|
|
AuthProviderTypePassword AuthProviderType = "password"
|
|
AuthProviderTypeOauth AuthProviderType = "oauth"
|
|
)
|
|
|
|
type AuthProvider interface {
|
|
GetName() string
|
|
GetType() AuthProviderType
|
|
GetPriority() int // lower number = higher priority
|
|
|
|
Login(*AuthContext) (string, error)
|
|
Logout(*AuthContext) error
|
|
GetUserModel(*AuthContext) (*User, error)
|
|
|
|
SetupRoutes(routes *gin.RouterGroup)
|
|
}
|