internal

package
v0.0.0-...-0b0dee4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestStorage  = make([]AuthenticateRequest, 0)
	ClientStorage   = make([]Client, 0)
	UserStorage     = make([]User, 0)
	AuthCodeStorage = make([]AuthCode, 0)
	TokenStorage    = make([]Token, 0)
)
View Source
var (
	ErrAuthReqDoesNotExist = fmt.Errorf("auth request does not exist")
)

Functions

func AuthErrorResponse

func AuthErrorResponse(w http.ResponseWriter, r *http.Request, authReq AuthenticateRequest, 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(username, password, authReqID string) error

func ValidateClientRedirectURI

func ValidateClientRedirectURI(clientID string, redirectURI string) (bool, error)

returns true if redirectURI is valid for clientID, otherwise false

Types

type AuthCode

type AuthCode struct {
	ID            string
	AuthRequestID string
	Scope         []string
	ClientID      string
	RedirectURI   string
	State         string
}

type AuthCode string

func GenerateAuthCode

func GenerateAuthCode(authReq AuthenticateRequest) (AuthCode, error)

add auth code obj to auth code storage and returns new created auth code

func (AuthCode) GetID

func (c AuthCode) GetID() string

type AuthenticateRequest

type AuthenticateRequest struct {
	Scope         []string
	ResponseType  []string
	ClientID      string
	RedirectURI   string
	State         string
	AuthRequestID string
}

func (AuthenticateRequest) GetID

func (a AuthenticateRequest) GetID() string

type Client

type Client struct {
	ID           string
	Secret       string
	RedirectURIs []string
}

func (Client) GetID

func (c Client) GetID() string

type Token

type Token struct {
	Scopes      []string
	ID          string
	ClientID    string
	AccessToken string
}

func SwitchCodeToToken

func SwitchCodeToToken(authCode AuthCode) (Token, error)

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

func (Token) GetID

func (t Token) GetID() string

type User

type User struct {
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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