authik

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 9 Imported by: 0

README

authik-go

Authik SDK for Go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionTokenMissing = errors.New("authik: provided request did not have a session token in its cookies")
	ErrSessionTokenExpired = errors.New("authik: session token has expired")
	ErrSessionTokenInvalid = errors.New("authik: session token is invalid")
)

Functions

func Bool

func Bool(v bool) *bool

func String

func String(v string) *string

Types

type APIError

type APIError struct {
	Resource string `json:"resource"`
	Type     string `json:"type"`
	Code     string `json:"code"`
	Message  string `json:"message"`
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(secretKey string) (*Client, error)

func PrivateNew

func PrivateNew(secretKey string, privateOptions *PrivateOptions) (*Client, error)

func (*Client) GetUser

func (client *Client) GetUser(id string) (*User, error)

func (*Client) VerifySessionToken

func (client *Client) VerifySessionToken(token string) (*SessionToken, error)

func (*Client) VerifySessionTokenRequest

func (client *Client) VerifySessionTokenRequest(request *http.Request) (*SessionToken, error)

type Email

type Email struct {
	ID          string      `json:"id"`
	Resource    string      `json:"resource"`
	CreatedAt   string      `json:"created_at"`
	Status      EmailStatus `json:"status"`
	Address     string      `json:"address"`
	VerifiedAt  *string     `json:"verified_at"`
	VerifiedVia *struct {
		Type    EmailVerifiedViaType `json:"type"`
		LoginID *string              `json:"login_id"`
	} `json:"verified_via"`
}

type EmailStatus

type EmailStatus string
const (
	EmailStatusUnverified EmailStatus = "unverified"
	EmailStatusVerified   EmailStatus = "verified"
)

type EmailVerifiedViaType

type EmailVerifiedViaType string
const (
	EmailVerifiedViaTypeLogin EmailVerifiedViaType = "login"
)

type PrivateOptions

type PrivateOptions struct {
	APIURL *string
}

type SessionToken

type SessionToken struct {
	UserID    string
	SessionID string
	IssuedAt  time.Time
	ExpiresAt time.Time
	Value     string
}

type User

type User struct {
	ID        string `json:"id"`
	Resource  string `json:"resource"`
	CreatedAt string `json:"created_at"`

	Name        *string `json:"name"`
	NameDetails *struct {
		GivenName  *string `json:"given_name"`
		FamilyName *string `json:"family_name"`
	} `json:"name_details"`
	EmailID      *string `json:"email_id"`
	Email        *Email
	EmailAddress *string `json:"email_address"`
	AvatarURL    *string `json:"avatar_url"`

	LastLoginAt *string `json:"last_login_at"`
}

Jump to

Keyboard shortcuts

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