client

package
v0.0.0-...-173cbd8 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPublicKey is the default public key for token and refresh token
	DefaultPublicKey = prototoken.NewHMACPublicKey([]byte("DefaultSecret"))
)

Functions

func Expired

func Expired(token string) (bool, error)

Expired checks if token has expired

func HasPermission

func HasPermission(token *proto.Token, permission string) bool

HasPermission returns true if the user has a permission

func UID

func UID(token *proto.Token) string

UID returns the user id contained in the token

Types

type Client

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

Client performs auth requests against the service

func NewClient

func NewClient(client client.Client, service string, opts ...Option) *Client

NewClient creates an auth client

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, username string, password string) (*proto.Response, error)

Auth performs an auth request against the service

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, token string) (*proto.Response, error)

Refresh performs a refresh request against the service

func (*Client) Validate

func (c *Client) Validate(token string) (*proto.Token, error)

Validate validates a token locally this will fail on refresh tokens

type Option

type Option func(*options)

Option is a options for client or service

func PublicKeyHMAC

func PublicKeyHMAC(secret []byte) Option

PublicKeyHMAC sets the public key for both tokens and refresh tokens

func PublicKeyRSA

func PublicKeyRSA(key *rsa.PublicKey) Option

PublicKeyRSA sets the public key for both tokens and refresh tokens

Jump to

Keyboard shortcuts

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