token

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcBs160

func CalcBs160() string

CalcBs160 generates random with 160bit hex series

func CalcBs32

func CalcBs32() string

CalcBs32 generates random hex with 32bit unsigned integer and return it as string

Types

type Store

type Store struct {
	Logger []io.Writer //logging interface
	// contains filtered or unexported fields
}

Store is session token storage with in-memory data. That holds uniq server session id for the LDAP connection, and a map of client session which is keyed by hashed set of ip address and client user agent string.

func NewStore

func NewStore(customHeader string, logWriters ...io.Writer) Store

NewStore generates new token.Store instance, which represents in-memory temporary token store. FIXME: implement salt and regenerate accessToken in effective sequence (against rainbow table attack)

func (Store) Authorize

func (sess Store) Authorize(h httprouter.Handle, _ ...string) httprouter.Handle

Authorize provides local authorization handler for httprouter.Handle handlers. This method searches client information in Store and matches header value with the secret registered in userSessions.

If the matched result is success, it provides protected route for the client.

[Note] customHeader is used for the authentication.

func (*Store) GetAccessToken

func (sess *Store) GetAccessToken() string

GetAccessToken returns preset access token.

func (Store) Log

func (sess Store) Log(logLine string) (errorArray []error)

Log provides internal logging mechanism for Store

func (*Store) RegenerateToken

func (sess *Store) RegenerateToken() string

RegenerateToken recreates access token with CalcBs32 and returns it.

func (Store) RegisterClient

func (sess Store) RegisterClient(r *http.Request) (string, error)

RegisterClient generates new secret and registers client and its secret in Store.

func (Store) RevokeClient

func (sess Store) RevokeClient(r *http.Request) error

RevokeClient revokes registered client for the session. This method removes registered credential for the client

Jump to

Keyboard shortcuts

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