utils

package
v0.0.0-...-57ebffe Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidRequest          string = "invalid_request"
	UnauthorizedClient      string = "unauthorized_client"
	AccessDenied            string = "access_denied"
	UnsupportedResponseType string = "unsupported_response_type"
	InvalidScope            string = "invalid_scope"
	ServerError             string = "server_error"
	TemporaryUnavailable    string = "temporary_unavailable"
)

this are error codes in callback response

Variables

This section is empty.

Functions

func AuthErrorResponse

func AuthErrorResponse(clientStorage storage.Client, w http.ResponseWriter, r *http.Request, authReq oidc.AuthRequest, errorCode string)

returns json object with errorCode, also it has redirection uri with error params errorCode - is OAuth Error code (https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2), you can find then in pkg

func CheckUsernamePassword

func CheckUsernamePassword(userStorage storage.User, requestStorage storage.AuthRequest, username, password, authReqID string) error

func Contains

func Contains[T comparable](sl []T, elem T) bool

func GenerateAuthCode

func GenerateAuthCode(requestStorage storage.AuthRequest, authCodeStorage storage.AuthCode, authReq oidc.AuthRequest, username string) (oidc.AuthCode, error)

add auth code obj to auth code storage and returns new created auth code delete auth request and get auth code

func ResponseJSON

func ResponseJSON(w http.ResponseWriter, code int, payload any) error

func SwitchCodeToToken

func SwitchCodeToToken(authCodeStorage storage.AuthCode, tokenStorage storage.AccessToken, authCode oidc.AuthCode, redirectURI string, grantType string) (oidc.AccessToken, error)

Requires authRequest obj, deletes it and add generated token into token storage

func ValidateClientRedirectURI

func ValidateClientRedirectURI(clientStorage storage.Client, clientID string, redirectURI string) (bool, error)

returns true if redirectURI is valid for clientID, otherwise false

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, message string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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