oidc

package
v2.3.219 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerIsNotUnavailable = apperr.New("oidc_server_is_not_unavailable", apperr.WithTextTranslate(translator.Translate{translator.RU: "Сервер недоступен", translator.EN: "Server is unavailable"}), apperr.WithCode(code.Unavailable))
	ErrInvalidState           = apperr.New("oidc_invalid_state", apperr.WithTextTranslate(translator.Translate{translator.RU: "Неизвестный источник", translator.EN: "Unknown source"}), apperr.WithCode(code.InvalidArgument))
	ErrInvalidCode            = apperr.New("oidc_invalid_code", apperr.WithTextTranslate(translator.Translate{translator.RU: "Неизвестный код", translator.EN: "Unknown code"}), apperr.WithCode(code.InvalidArgument))
	ErrInvalidToken           = apperr.New("oidc_invalid_token", apperr.WithTextTranslate(translator.Translate{translator.RU: "Неверный токен", translator.EN: "Invalid token"}), apperr.WithCode(code.InvalidArgument))
	ErrInvalidAttribute       = apperr.New("oidc_invalid_attribute", apperr.WithTextTranslate(translator.Translate{translator.RU: "Неверный аттрибут", translator.EN: "Invalid attribute"}), apperr.WithCode(code.InvalidArgument))
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(ctx context.Context, cfg Config) (*Auth, error)

func (*Auth) CheckRedirectURLs

func (auth *Auth) CheckRedirectURLs(redirectURL string) bool

func (*Auth) IsEnabled

func (auth *Auth) IsEnabled() bool

func (*Auth) Refresh

func (auth *Auth) Refresh(ctx context.Context, token string) (*Token, error)

func (*Auth) SumState

func (auth *Auth) SumState(redirectURL string, deviceID int) (string, string, error)

func (*Auth) SumStateAny added in v2.3.167

func (auth *Auth) SumStateAny(state any) (string, string, error)

func (*Auth) Verify

func (auth *Auth) Verify(ctx context.Context, state string, code string) (*Token, error)

func (*Auth) VerifyAny added in v2.3.167

func (auth *Auth) VerifyAny(ctx context.Context, state string, code string, s any) (*Token, error)

type AuthService

type AuthService interface {
	IsEnabled() bool
	SumState(redirectURL string, deviceID int) (string, string, error)
	SumStateAny(state any) (string, string, error)
	Verify(ctx context.Context, state string, code string) (*Token, error)
	VerifyAny(ctx context.Context, state string, code string, s any) (*Token, error)
	Refresh(ctx context.Context, token string) (*Token, error)
	CheckRedirectURLs(redirectURL string) bool
}

type Config

type Config struct {
	Enabled           bool
	ConfigURL         string
	ClientID          string
	ClientSecret      string
	RootURL           string
	LoginAttr         string
	ValidRedirectURLs []string
}

type StateCode

type StateCode struct {
	Rand        string `json:"rand"`
	RedirectURL string `json:"redirect_url"`
	DeviceID    int    `json:"device_id"`
}

type Token

type Token struct {
	IDToken *oauth2.Token
	Login   *string
	State   *StateCode
}

Jump to

Keyboard shortcuts

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