oidc

package
v2.3.152 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) Verify

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

type AuthService

type AuthService interface {
	IsEnabled() bool
	SumState(redirectURL string, deviceID int) (string, string, error)
	Verify(ctx context.Context, state string, code string) (*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