api

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAuthentication indicates an invalid authentication
	ErrInvalidAuthentication = errors.New("invalid authentication")
)

Functions

func WriteError

func WriteError(err error, response *restful.Response)

Write error in good http format with error stack in it

Types

type API

type API struct {
	CRTData       []byte
	Authenticator Authenticator
	PublicKey     interface{}
	PrivateKey    interface{}
	SigningMethod jwt.SigningMethod
	TokenDuration time.Duration
}

API registering with restful

func (*API) Register

func (api *API) Register() *restful.WebService

Register provide a restful.WebService from this API

type AuthReq

type AuthReq struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

AuthReq is a simple authn request

type AuthResponse

type AuthResponse struct {
	Token  string     `json:"token"`
	Claims jwt.Claims `json:"claims"`
}

AuthResponse is a simple JWT authn response

type Authenticator

type Authenticator interface {
	Authenticate(user, password string, expiresAt time.Time) (claims jwt.Claims, err error)
}

Authenticator is the interface for authn backends

type KeystoneAuth

type KeystoneAuth struct {
	Identity struct {
		Methods  []string `json:"methods"`
		Password struct {
			User struct {
				ID       string `json:"id,omitempty"`
				Name     string `json:"name,omitempty"`
				Password string `json:"password"`
				Domain   struct {
					ID   string `json:"id,omitempty"`
					Name string `json:"name,omitempty"`
				} `json:"domain"`
			} `json:"user"`
		} `json:"password"`
	} `json:"identity"`
}

KeystoneAuth is a Keystone API like auth

type KeystoneAuthReq

type KeystoneAuthReq struct {
	Auth *KeystoneAuth `json:"auth"`
}

KeystoneAuthReq is a Keystone API like auth request

type KeystoneAuthResponse

type KeystoneAuthResponse struct {
	Token struct {
		IssuedAt  time.Time `json:"issued_at"`
		ExpiresAt time.Time `json:"expires_at"`
		User      struct {
			ID   string `json:"id,omitempty"`
			Name string `json:"name,omitempty"`
		} `json:"user"`
	} `json:"token"`
}

KeystoneAuthResponse is a Keystone API like auth response

Jump to

Keyboard shortcuts

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