auth

package
v0.0.0-...-c2a4aac Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 16 Imported by: 7

Documentation

Index

Constants

View Source
const (
	TOKEN_VALUES tlv.Type = iota
	TOKEN_SIGNATURE
	T_TENANT_ID
	T_CLIENT_ID
	T_NOT_BEFORE
	T_NOT_AFTER
	T_SCOPE
)
View Source
const (
	KEY_CLIENT_ID_SECRET    = "client-id-secret"
	KEY_TOKEN_SIGNATURE_KEY = "token-signature-key"
)
View Source
const (
	ASSET_AUTH_PUBKEY = "auth-pubkey"
)
View Source
const (
	SCOPE_ADMIN tlv.Type = iota
)

Variables

View Source
var (
	TokenSymtab = tlv.Symtab{
		TOKEN_VALUES: tlv.Symbol{
			Name: "values",
			Child: tlv.Symtab{
				T_TENANT_ID: tlv.Symbol{
					Name: "tenant_id",
				},
				T_CLIENT_ID: tlv.Symbol{
					Name: "client_id",
				},
				T_NOT_BEFORE: tlv.Symbol{
					Name: "not_before",
				},
				T_NOT_AFTER: tlv.Symbol{
					Name: "not_after",
				},
				T_SCOPE: tlv.Symbol{
					Name: "scope",
					Child: tlv.Symtab{
						SCOPE_ADMIN: tlv.Symbol{
							Name: "admin",
						},
					},
				},
			},
		},
		TOKEN_SIGNATURE: tlv.Symbol{
			Name: "signature",
		},
	}
)

Functions

func Authorize

func Authorize(w http.ResponseWriter, r *http.Request, realm string,
	signatureVerifier func(message, sig []byte) bool,
	tenant *Tenant) tlv.Values

func BasicAuth

func BasicAuth(username, password string) string

func Error401

func Error401(w http.ResponseWriter, realm string)

func Error401f

func Error401f(w http.ResponseWriter, realm, error, desc string,
	a ...interface{})

func ParseBasicAuth

func ParseBasicAuth(authorization string) (username, password string, ok bool)

func VerifyClientCredentials

func VerifyClientCredentials(id, secret string, clientIDSecret []byte) bool

func VerifyToken

func VerifyToken(token []byte, pub ed25519.PublicKey) bool

Types

type Asset

type Asset struct {
	Name string
	Data []byte
}

func UnmarshalAsset

func UnmarshalAsset(data map[string]interface{}) (*Asset, error)

type Client

type Client struct {
	ID       string
	Secret   string
	TenantID string
	Name     string
}

func UnmarshalClient

func UnmarshalClient(data map[string]interface{}) (*Client, error)

func (*Client) CreateSecret

func (c *Client) CreateSecret(clientIDSecret []byte) error

type ClientStore

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

func NewClientStore

func NewClientStore() (*ClientStore, error)

func (*ClientStore) Asset

func (store *ClientStore) Asset(name string) ([]*Asset, error)

func (*ClientStore) Client

func (store *ClientStore) Client(id string) ([]*Client, error)

func (*ClientStore) Clients

func (store *ClientStore) Clients() ([]*Client, error)

func (*ClientStore) Close

func (store *ClientStore) Close() error

func (*ClientStore) NewAsset

func (store *ClientStore) NewAsset(name string, data []byte) (*Asset, error)

func (*ClientStore) NewClient

func (store *ClientStore) NewClient(tenant string, name string,
	clientIDSecret []byte) (*Client, error)

func (*ClientStore) NewTenant

func (store *ClientStore) NewTenant(name string) (*Tenant, error)

func (*ClientStore) Tenant

func (store *ClientStore) Tenant(id string) ([]*Tenant, error)

func (*ClientStore) TenantByName

func (store *ClientStore) TenantByName(name string) ([]*Tenant, error)

func (*ClientStore) Tenants

func (store *ClientStore) Tenants() ([]*Tenant, error)

type ID

type ID [8]byte

func NewID

func NewID() (ID, error)

func ParseID

func ParseID(val string) (ID, error)

func (ID) String

func (id ID) String() string

type OAuth2Client

type OAuth2Client struct {
	TokenEndpoint string
	// contains filtered or unexported fields
}

func NewOAuth2Client

func NewOAuth2Client(id, secret, token string) *OAuth2Client

func (*OAuth2Client) GetToken

func (client *OAuth2Client) GetToken() (*TokenResponse, error)

type Tenant

type Tenant struct {
	ID   string
	Name string
}

func UnmarshalTenant

func UnmarshalTenant(data map[string]interface{}) (*Tenant, error)

type TenantID

type TenantID [8]byte

func ParseTenantID

func ParseTenantID(val string) (TenantID, error)

func (TenantID) String

func (id TenantID) String() string

type TokenResponse

type TokenResponse struct {
	AccessToken      string `json:"access_token"`
	TokenType        string `json:"token_type"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

Jump to

Keyboard shortcuts

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