authentication

package
v0.0.0-...-953ae9e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountsUrl = "http://localhost:3000/accounts"
	Origin      = "http://localhost:3000"
)

Variables

This section is empty.

Functions

func ExtractClaims

func ExtractClaims(tokenStr string) (uint32, error)

Types

type AccountResult

type AccountResult struct {
	Id       string `json:"id"`
	Username string `json:"username"`
	Locked   bool   `json:"locked"`
	Deleted  bool   `json:"deleted"`
}

type AggregatedError

type AggregatedError struct {
	AuthErrorMsg *AuthError `json:"authentication_error"`
	Error        error      `json:"error"`
}

func ExtractErrorResponse

func ExtractErrorResponse(resp *http.Response, err error, body []byte, authError AuthError) (*AggregatedError, bool)

type AuthAccount

type AuthAccount struct {
	Result AccountResult `json:"result"`
}

type AuthError

type AuthError struct {
	AuthErrorMessage []ErrorFields `json:"errors"`
}

type Authentication

type Authentication struct {
	Origin                           string
	AccountsBase                     string
	SessionBase                      string
	Availability                     string
	Import                           string
	RefreshSession                   string
	EnablePrivateEndpointInteraction bool
}

func NewAuthenticationService

func NewAuthenticationService(origin string, enablePrivateEndpointInteraction bool) *Authentication

Obtain authentication service

func (*Authentication) DeleteAccount

func (a *Authentication) DeleteAccount(username, password string, id uint32) *AggregatedError

func (*Authentication) GetAccount

func (a *Authentication) GetAccount(id uint32, username, password string) (*AggregatedError, *AuthAccount)

func (*Authentication) GetJwks

func (a *Authentication) GetJwks(uri string) (*AggregatedError, *JsonKeys)

func (*Authentication) GetJwtPublicKey

func (a *Authentication) GetJwtPublicKey() (*AggregatedError, *JwtConfiguration)

func (*Authentication) IsUsernameAvailable

func (a *Authentication) IsUsernameAvailable(username string) (*AggregatedError, bool)

func (*Authentication) LockOrUnlockAccount

func (a *Authentication) LockOrUnlockAccount(id int, username, password string, lock bool) *AggregatedError

func (*Authentication) LogOut

func (a *Authentication) LogOut() *AggregatedError

func (*Authentication) Login

func (a *Authentication) Login(username, password string) (*AggregatedError, *string)

func (*Authentication) RefreshToken

func (a *Authentication) RefreshToken() (*AggregatedError, *TokenId)

func (*Authentication) SetHeadersAndPerformRequest

func (a *Authentication) SetHeadersAndPerformRequest(request *http.Request, username, password string, isPublic bool) (error, *http.Response)

func (*Authentication) SignUp

func (a *Authentication) SignUp(username, password string) (*AggregatedError, *TokenId)

func (*Authentication) UpdateAccount

func (a *Authentication) UpdateAccount(username, password string, locked bool) (*AggregatedError, int)

func (*Authentication) UpdateUsername

func (a *Authentication) UpdateUsername(username, password string, id uint32) *AggregatedError

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ErrorFields

type ErrorFields struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

type IdResult

type IdResult struct {
	Id string `json:"id_token"`
}

type JsonKeys

type JsonKeys struct {
	Result []JsonWebKeys `json:"keys"`
}

type JsonWebKeys

type JsonWebKeys struct {
	Use string `json:"use"`
	Alg string `json:"alg"`
	Kty string `json:"kty"`
	Kid string `json:"kid`
	E   string `json:"e"`
	N   string `json:"n"`
}

type JwtConfiguration

type JwtConfiguration struct {
	Issuer                 string   `json:"issuer"`
	ResponseTypesSupported []string `json:"response_types_supported"`
	SubjectTypesSupported  []string `json:"subject_types_supported"`
	TokenSigningAlgo       []string `json:"id_token_signing_alg_values_supported"`
	ClaimsSupported        []string `json:"claims_supported"`
	JwtPublicKeyURI        string   `json:"jwks_uri"`
}

type LoginAccount

type LoginAccount struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type ParseJwtResponse

type ParseJwtResponse struct {
	Auth     []string         `json:"aud"`
	AuthTime *jwt.NumericDate `json:"auth_time"`
	Exp      *jwt.NumericDate `json:"exp"`
	Iat      *jwt.NumericDate `json:"iat"`
	Iss      string           `json:"iss"`
	Sub      string           `json:"sub"`
}

type TokenId

type TokenId struct {
	Result TokenResult `json:"result"`
}

type TokenResult

type TokenResult struct {
	Token string `json:"id_token"`
}

type UpdateAccount

type UpdateAccount struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Locked   bool   `json:"locked"`
}

type UpdateAccountResponse

type UpdateAccountResponse struct {
	Result IdResult `json:"result"`
}

type UsernamePayload

type UsernamePayload struct {
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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