mirror of
https://github.com/h44z/wg-portal.git
synced 2025-12-14 18:46:17 +00:00
WIP: new user management and authentication system, use go 1.16 embed
This commit is contained in:
31
internal/authentication/provider.go
Normal file
31
internal/authentication/provider.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user