anauth

package
v0.0.0-...-2c216b4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MIN_SESSION_KEY_BYTE_LEN = 24

MIN_SESSION_KEY_BYTE_LEN represents the minimal allowed length of the session key in bytes, for security reasons.

Variables

View Source
var DEFAULT_TIMEOUT_MILLIS = 5000

Functions

func GetConnection

func GetConnection(addr string, opts ...ConnOption) (*grpc.ClientConn,
	error)

GetConnection accepts address addr where a gRPC server is listening, and ConnOptions to configure the connection. It returns a connection that a client can use to contact the server or error in case of misconfiguration. // FIXME

Note that several clients can be passed the same connection, as the gRPC framework is able to multiplex several RPCs on the same connection, thus reducing the overhead.

func GetLogger

func GetLogger() log.Logger

GetLogger returns the instance of log.Logger currently configured for this package.

func SetLogger

func SetLogger(lgr log.Logger)

SetLogger assigns the log.Logger instance passed as argument to the logger of this package. This is to support loggers other than log.StdoutLogger, which is set as default in init function.

Types

type ConnOption

type ConnOption func(*connOptions)

ConnOption is used to configure a connection to the server.

func WithCACert

func WithCACert(caCert []byte) ConnOption

WithCACert sets the CA certificate for validating the server and returns the ConnOption.

func WithServerNameOverride

func WithServerNameOverride(override string) ConnOption

WithServerNameOverride sets the string that will be compared to the CN field from server's cert during validation, and returns the ConnOption. This allows validation to pass even if server's hostname differs from certificate's CN.

func WithTimeout

func WithTimeout(millis int) ConnOption

WithTimeout sets a timeout in milliseconds for establishing initial connection with the server.

type GrpcServer

type GrpcServer struct {
	*grpc.Server
	Logger log.Logger
	// contains filtered or unexported fields
}

func NewGrpcServer

func NewGrpcServer(certFile, keyFile string, logger log.Logger) (*GrpcServer, error)

NewGrpcServer initializes an instance of the GrpcServer struct and returns a pointer. It performs some default configuration (tracing of gRPC communication and interceptors) and registers RPC server handlers with gRPC server. It requires TLS cert and keyfile in order to establish a secure channel with clients.

func (*GrpcServer) EnableTracing

func (s *GrpcServer) EnableTracing()

EnableTracing instructs the gRPC framework to enable its tracing capability, which is mainly used for debugging purposes. Although this function does not explicitly affect the GrpcServer struct, it is wired to GrpcServer in order to provide a nicer API when setting up the server.

func (*GrpcServer) RegisterService

func (s *GrpcServer) RegisterService(r Service) error

RegisterService registers a Service service to the underlying gRPC server. It returns an error if a service is already registered.

func (*GrpcServer) Start

func (s *GrpcServer) Start(port int) error

Start configures and starts the protocol server at the requested port.

func (*GrpcServer) Teardown

func (s *GrpcServer) Teardown()

Teardown stops the protocol server by gracefully stopping enclosed gRPC server.

type RandSessionKeyGen

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

RandSessionKeyGen generates session keys of the desired byte length from random bytes.

func NewRandSessionKeyGen

func NewRandSessionKeyGen(byteLen int) (*RandSessionKeyGen, error)

NewRandSessionKeyGen creates a new RandSessionKeyGen instance. The new instance will be configured to generate session keys with exactly byteLen bytes. For security reasons, the function checks the byteLen against the value of MIN_SESSION_KEY_BYTE_LEN. If the provided byteLen is smaller than MIN_SESSION_KEY_BYTE_LEN, an error is set and the returned RandSessionKeyGen is configured to use MIN_SESSION_KEY_BYTE_LEN instead of the provided byteLen.

func (*RandSessionKeyGen) GenerateSessionKey

func (m *RandSessionKeyGen) GenerateSessionKey() (*string, error)

GenerateSessionKey produces a secure random session key and returns its base64-encoded representation that is URL-safe. It reports an error in case random byte sequence could not be generated.

type RedisClient

type RedisClient struct {
	*redis.Client
}

func NewRedisClient

func NewRedisClient(c *redis.Client) *RedisClient

func (*RedisClient) CheckRegistrationKey

func (c *RedisClient) CheckRegistrationKey(key string) (bool, error)

CheckRegistrationKey checks whether provided key is present in registration database and deletes it, preventing another registration with the same key. Returns true if key was present (registration allowed), false otherwise.

type RedisSessStorer

type RedisSessStorer struct {
	*redis.Client
}

func NewRedisSessStorer

func NewRedisSessStorer(c *redis.Client) *RedisSessStorer

func (*RedisSessStorer) Store

func (s *RedisSessStorer) Store(key string) error

type RegManager

type RegManager interface {
	CheckRegistrationKey(string) (bool, error)
}

SessManager checks for the presence of a registration key, removing it in case it exists. The bolean return argument indicates success (registration key present and subsequently deleted) or failure (absence of registration key).

type Service

type Service interface {
	RegisterTo(*grpc.Server)
}

Service registers a grpc service handler to a grpc.GrpcServer passed as argument.

type SessManager

type SessManager interface {
	GenerateSessionKey() (*string, error)
}

SessManager generates a new session key. It returns a string containing the generated session key or an error in case session key could not be generated.

type SessStorer

type SessStorer interface {
	Store(string) error
}

SessStorer stores arbitrary data associated with the authenticated session to the storage backend, returning error in case the data could not be stored.

Directories

Path Synopsis
cl
clpb
Package clpb is a generated protocol buffer package.
Package clpb is a generated protocol buffer package.
Package compatibility implements wrapper types, constants and functions around github.com/emmyzkp/emmy/client, making relevant functionality compatible with go language binding tools.
Package compatibility implements wrapper types, constants and functions around github.com/emmyzkp/emmy/client, making relevant functionality compatible with go language binding tools.
ecpsyspb
Package ecpsyspb is a generated protocol buffer package.
Package ecpsyspb is a generated protocol buffer package.
psyspb
Package psyspb is a generated protocol buffer package.
Package psyspb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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