auth

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateDapp    string = "create:dapp"
	CreateChannel string = "create:channel"
	CreateType    string = "create:type"
	CreateAlias   string = "create:alias"
	CreateBroker  string = "create:broker"

	GetDapp    string = "get:dapp"
	GetChannel string = "get:channel"
	GetType    string = "get:type"
	GetAlias   string = "get:alias"
	GetBroker  string = "get:broker"

	UpdateDapp    string = "update:dapp"
	UpdateChannel string = "update:channel"
	UpdateType    string = "update:type"
	UpdateAlias   string = "update:alias"

	DeleteDapp    string = "delete:dapp"
	DeleteChannel string = "delete:channel"
	DeleteType    string = "delete:type"
	DeleteAlias   string = "delete:alias"

	CreateToken string = "create:token"
)

All Permissions possible values

Variables

View Source
var AdminPermissions = map[string][]string{

	CreateAlias: {""},
	DeleteAlias: {""},
	GetAlias:    {""},
	UpdateAlias: {""},

	CreateChannel: {""},
	DeleteChannel: {""},
	GetChannel:    {""},
	UpdateChannel: {""},

	CreateDapp: {""},
	DeleteDapp: {""},
	GetDapp:    {""},
	UpdateDapp: {""},

	CreateType: {""},
	DeleteType: {""},
	GetType:    {""},
	UpdateType: {""},

	GetBroker:    nil,
	CreateBroker: nil,

	CreateToken: nil,
}

AdminPermissions defines all the permissions that the admin user have when the cluster is initialized

Functions

func GetPublicKey

func GetPublicKey() (*rsa.PublicKey, error)

GetPublicKey resolves the rsa public key from the environment variable

Types

type Auth

type Auth interface {
	Validate(token []byte) (*Payload, []byte, error)
	Tokenize(load Payload) ([]byte, error)
	Init(key string, load Payload) ([]byte, error)
	Refresh(token []byte) ([]byte, error)
}

Auth is the inteface for interacting with the Authentication service

type Authenticator

type Authenticator struct {
	TokenPath string
}

Authenticator is responsible for implementing the interface methods defined in the rest/request pkg.

func (Authenticator) GetToken

func (a Authenticator) GetToken() ([]byte, error)

GetToken read the token from the file specified in the struct TokenPath and returns it's bytes

func (Authenticator) SetToken

func (a Authenticator) SetToken(token []byte) error

SetToken receives a new token as a parameter and then writes it in the file specified in the TokenPath

type InitDO

type InitDO struct {
	Payload
	Key string
}

InitDO structure for initialization requests

type JwtDO

type JwtDO struct {
	Token []byte `json:"token"`
}

JwtDO is a data output type for master's token handler

type Payload

type Payload struct {
	UID string `json:"uid"`
	// Permissions is a map where key is the Scope and values are permissions
	Permissions map[string][]string `json:"permissions"`
	Refresh     []byte              `json:"refresh"`
	RefreshURL  string              `json:"refreshurl"`
}

Payload is information caried by a Inspr acceess token

func Desserialize

func Desserialize(tokenBytes []byte) (*Payload, error)

Desserialize converts a token to a Payload model

func (*Payload) ImportPermissionList added in v0.1.4

func (pld *Payload) ImportPermissionList(permissions []string, scope string)

ImportPermissionList converts Dapps auth permission scheme to paylod permissions

type ResfreshDO

type ResfreshDO struct {
	RefreshToken []byte `json:"refreshtoken"`
}

ResfreshDO is the body type expected by UID provider to refresh a payload

Directories

Path Synopsis
Package jwtauth is responsible for implementing the auth methods specified in the auth folder of the inspr pkg.
Package jwtauth is responsible for implementing the auth methods specified in the auth folder of the inspr pkg.

Jump to

Keyboard shortcuts

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