client

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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client defines a Redis client, which has the interface methods

func NewRedisClient

func NewRedisClient() *Client

NewRedisClient creates and returns a new Redis client

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, uid, pwd string, newUser User) error

CreateUser inserts a new user into Redis

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, uid, pwd, usrToBeDeleted string) error

DeleteUser deletes an user from Redis, if it exists

func (*Client) Login

func (c *Client) Login(ctx context.Context, uid, pwd string) (string, error)

Login receives an user and a password, and checks if they exist and match. If so, it sends a request to Insprd so it can generate a new token for the given user, and returns the toker if it's creation was successful

func (*Client) RefreshToken

func (c *Client) RefreshToken(ctx context.Context, refreshToken []byte) (*auth.Payload, error)

RefreshToken receives a refreshToken and checks if it's valid. If so, it returns a payload containing the updated user info (user which is associated with the given refreshToken)

func (*Client) UpdatePassword

func (c *Client) UpdatePassword(ctx context.Context, uid, pwd, usrToBeUpdated, newPwd string) error

UpdatePassword changes an users password, if that user exists

type RedisManager

type RedisManager interface {
	UIDClient
	RefreshToken(ctx context.Context, refreshToken []byte) (*auth.Payload, error)
}

RedisManager defines methods to manage Redis in the cluster

type UIDClient

type UIDClient interface {
	// creates payload and sends it to insprd
	// when creating the payload, generetes the Refresh Token (cryptografado)
	Login(ctx context.Context, uid, pwd string) (string, error) // asks Insprd to generate token and saves it into file
	CreateUser(ctx context.Context, uid, pwd string, newUser User) error
	DeleteUser(ctx context.Context, uid, pwd, usrToBeDeleted string) error
	UpdatePassword(ctx context.Context, uid, pwd, usrToBeUpdated, newPwd string) error
}

UIDClient is a client for communicating with inspr's uid provider

type User

type User struct {
	UID string `json:"uid"`
	// Permissions is a map where key is the Scope and values are permissions
	Permissions map[string][]string `json:"permissions"`
	Password    string              `json:"password"`
}

User defines the information a user contains

Jump to

Keyboard shortcuts

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