auth

package
v0.0.0-...-f726f7b Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const GoogleOAuthEndpoint = "https://www.googleapis.com/oauth2/v3"

GoogleOAuthEndpoint - endpoint for checking tokens

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultGeneralVerifier

type DefaultGeneralVerifier struct {
	Verifiers map[string]Verifier
}

DefaultGeneralVerifier is the defualt general verifier that is used

func (*DefaultGeneralVerifier) ListVerifiers

func (tgv *DefaultGeneralVerifier) ListVerifiers() []string

ListVerifiers gets List of Registered Verifiers

func (*DefaultGeneralVerifier) Lookup

func (tgv *DefaultGeneralVerifier) Lookup(verifierIdentifier string) (Verifier, error)

Lookup returns the appropriate verifier

func (*DefaultGeneralVerifier) Verify

func (tgv *DefaultGeneralVerifier) Verify(rawMessage *bijson.RawMessage) (bool, string, error)

Verify reroutes the json request to the appropriate sub-verifier within generalVerifier Returns result, verifierID and error

type DemoVerifier

type DemoVerifier struct {
	ExpectedKey string
	Store       map[string]bool
}

func (*DemoVerifier) CleanToken

func (v *DemoVerifier) CleanToken(token string) string

CleanToken - ensure that incoming token conforms to strict format to prevent replay attacks

func (*DemoVerifier) GetIdentifier

func (v *DemoVerifier) GetIdentifier() string

GetIdentifier - return identifier string for verifier

func (*DemoVerifier) VerifyRequestIdentity

func (v *DemoVerifier) VerifyRequestIdentity(jsonToken *bijson.RawMessage) (bool, string, error)

VerifyRequestIdentity - verifies identity of user based on their token

type DemoVerifierParams

type DemoVerifierParams struct {
	Index   int    `json:"index"`
	IDToken string `json:"idtoken"`
	Email   string `json:"email"`
}

type DiscordAuthResponse

type DiscordAuthResponse struct {
	Application struct {
		ID string `json:"id"`
	} `json:"application"`
	User struct {
		ID string `json:"id"`
	} `json:"user"`
	Expires string `json:"expires"`
}

type DiscordVerifier

type DiscordVerifier struct {
	Timeout time.Duration
}

func NewDiscordVerifier

func NewDiscordVerifier() *DiscordVerifier

func (*DiscordVerifier) CleanToken

func (d *DiscordVerifier) CleanToken(token string) string

func (*DiscordVerifier) GetIdentifier

func (d *DiscordVerifier) GetIdentifier() string

func (*DiscordVerifier) VerifyRequestIdentity

func (d *DiscordVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

type DiscordVerifierParams

type DiscordVerifierParams struct {
	IDToken    string `json:"idtoken"`
	VerifierID string `json:"verifier_id"`
}

type FacebookAuthResponse

type FacebookAuthResponse struct {
	Data struct {
		AppId               string `json:"app_id,omitempty"`
		Application         string `json:"application,omitempty"`
		DataAccessExpiresAt int    `json:"data_access_expiers_at,omitempty"`
		Error               *struct {
			Code    int    `json:"code"`
			Message string `json:"message"`
		} `json:"error,omitempty"`
		ExpiresAt int      `json:"expires_at,omitempty"`
		IsValid   bool     `json:"is_valid"`
		Scopes    []string `json:"scopes"`
		Type      string   `json:"type,omitempty"`
		UserID    string   `json:"user_id,omitempty"`
	} `json:"data"`
}

type FacebookVerifier

type FacebookVerifier struct{}

func NewFacebookVerifier

func NewFacebookVerifier() *FacebookVerifier

func (*FacebookVerifier) CleanToken

func (f *FacebookVerifier) CleanToken(token string) string

func (*FacebookVerifier) GetIdentifier

func (f *FacebookVerifier) GetIdentifier() string

func (*FacebookVerifier) VerifyRequestIdentity

func (f *FacebookVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

type FacebookVerifierParams

type FacebookVerifierParams struct {
	IDToken    string `json:"idtoken"`
	VerifierID string `json:"verifier_id"`
}

type GeneralVerifier

type GeneralVerifier interface {
	ListVerifiers() []string
	Verify(*bijson.RawMessage) (verified bool, verifierID string, err error)
	Lookup(string) (Verifier, error)
}

GeneralVerifier accepts an identifier string and returns an IdentityVerifier

func NewGeneralVerifier

func NewGeneralVerifier(verifiers []Verifier) GeneralVerifier

NewGeneralVerifier - Initialization function for a generic GeneralVerifier

type GoogleAuthResponse

type GoogleAuthResponse struct {
	Azp           string `json:"azp"`
	Email         string `json:"email"`
	Iss           string `json:"iss"`
	Aud           string `json:"aud"`
	Sub           string `json:"sub"`
	EmailVerified string `json:"email_verified"`
	AtHash        string `json:"at_hash"`
	Name          string `json:"name"`
	Picture       string `json:"picture"`
	GivenName     string `json:"given_name"`
	Locale        string `json:"locale"`
	Iat           string `json:"iat"`
	Exp           string `json:"exp"`
	Jti           string `json:"jti"`
	Alg           string `json:"alg"`
	Kid           string `json:"kid"`
	Typ           string `json:"typ"`
}

GoogleAuthResponse - expected response body from google endpoint when checking submitted token

type GoogleVerifier

type GoogleVerifier struct {
	Version  string
	Endpoint string
	Timeout  time.Duration
}

GoogleVerifier - Google verifier details

func NewGoogleVerifier

func NewGoogleVerifier() *GoogleVerifier

NewGoogleVerifier - Constructor for the default google verifier

func (*GoogleVerifier) CleanToken

func (g *GoogleVerifier) CleanToken(token string) string

CleanToken - trim spaces to prevent replay attacks

func (*GoogleVerifier) GetIdentifier

func (g *GoogleVerifier) GetIdentifier() string

GetIdentifier - get identifier string for verifier

func (*GoogleVerifier) VerifyRequestIdentity

func (g *GoogleVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

VerifyRequestIdentity - verifies identity of user based on their token

type GoogleVerifierParams

type GoogleVerifierParams struct {
	IDToken    string `json:"idtoken"`
	VerifierID string `json:"verifier_id"`
}

GoogleVerifierParams - expected params for the google verifier

type RedditAuthResponse

type RedditAuthResponse struct {
	Name          string `json:"name"`
	OAuthClientID string `json:"oauth_client_id"`
}

type RedditVerifier

type RedditVerifier struct{}

func NewRedditVerifier

func NewRedditVerifier() *RedditVerifier

func (*RedditVerifier) CleanToken

func (r *RedditVerifier) CleanToken(token string) string

func (*RedditVerifier) GetIdentifier

func (r *RedditVerifier) GetIdentifier() string

func (*RedditVerifier) VerifyRequestIdentity

func (r *RedditVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

type RedditVerifierParams

type RedditVerifierParams struct {
	IDToken    string `json:"idtoken"`
	VerifierID string `json:"verifier_id"`
}

type TestVerifier

type TestVerifier struct {
	CorrectIDToken string
}

func NewTestVerifier

func NewTestVerifier(correctIDToken string) *TestVerifier

NewTestVerifier - Constructor for the default test verifier

func (*TestVerifier) CleanToken

func (v *TestVerifier) CleanToken(token string) string

CleanToken - ensure that incoming token conforms to strict format to prevent replay attacks

func (*TestVerifier) GetIdentifier

func (v *TestVerifier) GetIdentifier() string

GetIdentifier - return identifier string for verifier

func (*TestVerifier) VerifyRequestIdentity

func (v *TestVerifier) VerifyRequestIdentity(jsonToken *bijson.RawMessage) (bool, string, error)

VerifyRequestIdentity - verifies identity of user based on their token

type TestVerifierParams

type TestVerifierParams struct {
	IDToken string `json:"idtoken"`
	ID      string `json:"id"`
}

type TorusRequest

type TorusRequest struct {
	VerifierID string  `json:"verifier_id"`
	Timestamp  big.Int `json:"timestamp"`
}

type TorusVerifier

type TorusVerifier struct {
	Timeout time.Duration
}

func NewTorusVerifier

func NewTorusVerifier() *TorusVerifier

func (*TorusVerifier) CleanToken

func (t *TorusVerifier) CleanToken(token string) string

func (*TorusVerifier) GetIdentifier

func (t *TorusVerifier) GetIdentifier() string

func (*TorusVerifier) VerifyRequestIdentity

func (t *TorusVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

type TorusVerifierParams

type TorusVerifierParams struct {
	VerifierID string  `json:"verifier_id"`
	Timestamp  big.Int `json:"timestamp"`
	IDToken    string  `json:"idtoken"`
}

type TwitchAuthResponse

type TwitchAuthResponse struct {
	AUD string `json:"aud"`
	EXP int    `json:"exp"`
	IAT int    `json:"iat"`
	ISS string `json:"iss"`
	SUB string `json:"sub"`
	AZP string `json:"azp"`
}

type TwitchVerifier

type TwitchVerifier struct {
	Timeout time.Duration
}

func NewTwitchVerifier

func NewTwitchVerifier() *TwitchVerifier

func (*TwitchVerifier) CleanToken

func (t *TwitchVerifier) CleanToken(token string) string

func (*TwitchVerifier) GetIdentifier

func (t *TwitchVerifier) GetIdentifier() string

func (*TwitchVerifier) VerifyRequestIdentity

func (t *TwitchVerifier) VerifyRequestIdentity(rawPayload *bijson.RawMessage) (bool, string, error)

type TwitchVerifierParams

type TwitchVerifierParams struct {
	IDToken    string `json:"idtoken"`
	VerifierID string `json:"verifier_id"`
}

type Verifier

type Verifier interface {
	GetIdentifier() string
	CleanToken(string) string
	VerifyRequestIdentity(*bijson.RawMessage) (verified bool, verifierID string, err error)
}

Verifier describes verification of a token, without checking for token uniqueness

type VerifierDetails

type VerifierDetails struct {
	Verifier   string
	VerifierID string
}

func (*VerifierDetails) FromVerifierDetailsID

func (v *VerifierDetails) FromVerifierDetailsID(vID VerifierDetailsID) error

func (*VerifierDetails) ToVerifierDetailsID

func (v *VerifierDetails) ToVerifierDetailsID() VerifierDetailsID

type VerifierDetailsID

type VerifierDetailsID string

type VerifyMessage

type VerifyMessage struct {
	Token              string `json:"idtoken"`
	VerifierIdentifier string `json:"verifieridentifier"`
}

Jump to

Keyboard shortcuts

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