auth

package
v0.0.0-...-6d36bb5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COOKIE_CSRF = "seventv-csrf"
	COOKIE_AUTH = "seventv-auth"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	SignJWT(secret string, claim jwt.Claims) (string, error)
	VerifyJWT(token []string, out jwt.Claims) (*jwt.Token, error)
	CreateCSRFToken(targetID primitive.ObjectID) (value, token string, err error)
	CreateAccessToken(targetID primitive.ObjectID, version float64) (string, time.Time, error)
	ValidateCSRF(state string, cookieData string) (*fasthttp.Cookie, *JWTClaimOAuth2CSRF, error)
	Cookie(key, token string, duration time.Duration) *fasthttp.Cookie
	QueryValues(provider structures.UserConnectionPlatform, csrfToken string) (url.Values, error)
	ExchangeCode(ctx context.Context, provider structures.UserConnectionPlatform, code string) (OAuth2AuthorizedResponse, error)
	TwichUserData(grant string) (string, []byte, error)
	DiscordUserData(grant string) (string, []byte, error)
	UserData(provider structures.UserConnectionPlatform, token string) (id string, b []byte, err error)
	LocateIP(ctx context.Context, ip string) (GeoIPResult, error)
}

func New

type AuthorizerOptions

type AuthorizerOptions struct {
	JWTSecret string
	Domain    string
	Secure    bool
	Config    configure.PlatformConfig
	Redis     redis.Instance
}

type GeoIPResult

type GeoIPResult struct {
	IP          string `json:"ip"`
	CountryName string `json:"country_name"`
	CountryCode string `json:"country_code2"`
}

type JWTClaimOAuth2CSRF

type JWTClaimOAuth2CSRF struct {
	State     string             `json:"s"`
	CreatedAt time.Time          `json:"at"`
	Bind      primitive.ObjectID `json:"bind"`

	jwt.RegisteredClaims
}

type JWTClaimUser

type JWTClaimUser struct {
	UserID       string  `json:"u"`
	TokenVersion float64 `json:"v"`

	jwt.RegisteredClaims
}

type KickUserData

type KickUserData struct {
	ID     int    `json:"id"`
	UserID int    `json:"user_id"`
	Slug   string `json:"slug"`
	User   struct {
		ID       int    `json:"id"`
		Username string `json:"username"`
		Bio      string `json:"bio"`
	} `json:"user"`
	Chatroom struct {
		ID int `json:"id"`
	} `json:"chatroom"`
}

type OAuth2AuthorizationParams

type OAuth2AuthorizationParams struct {
	ClientID     string `url:"client_id" json:"client_id"`
	ClientSecret string `url:"client_secret" json:"client_secret"`
	RedirectURI  string `url:"redirect_uri" json:"redirect_uri"`
	Code         string `url:"code" json:"code"`
	GrantType    string `url:"grant_type" json:"grant_type"`
	Scope        string `url:"scope" json:"scope"`
}

type OAuth2AuthorizedResponse

type OAuth2AuthorizedResponse struct {
	TokenType    string `json:"token_type"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
}

type OAuth2URLParams

type OAuth2URLParams struct {
	ClientID     string `url:"client_id"`
	RedirectURI  string `url:"redirect_uri"`
	ResponseType string `url:"response_type,omitempty"`
	GrantType    string `url:"grant_type,omitempty"`
	Scope        string `url:"scope"`
	State        string `url:"state"`
}

Jump to

Keyboard shortcuts

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