oauth

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuth

func NewAuth(provider OAuthProvider, config oauth2.Config, skipTlsVerify bool) *auth

NewAuth creates a new auth handler

func NewAuthInterceptor

func NewAuthInterceptor(groups []string) grpc.ServerOption

func RegisterOAuthProvider

func RegisterOAuthProvider(provier OAuthProvider)

Types

type OAuthProvider

type OAuthProvider interface {
	AllScopes() []string
	MinimalScopes() []string
	GetName() string
	GetServer() string
	SetServer(string)
	GetTokenURL() string
	GetAuthURL() string
	GetUserInfoURL() string
}

func GetOAuthProvider

func GetOAuthProvider(name string) OAuthProvider

type UserInfo

type UserInfo struct {
	Sub               string   `json:"sub"`
	Name              string   `json:"name"`
	PreferredUsername string   `json:"preferred_username"`
	Email             string   `json:"email"`
	Picture           string   `json:"picture"`
	Groups            []string `json:"groups"`
}

func GetUser

func GetUser(token string) *UserInfo

func GetUserFromContext

func GetUserFromContext(ctx context.Context) (user *UserInfo)

func GetUserInfo

func GetUserInfo(server OAuthProvider, token string, skipTlsVerify bool) (userInfo *UserInfo, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL