hive_go

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ok = iota
	BackendNotFound
	IncorrectToken
	InvalidToken
	SecretNotFound
)

Variables

View Source
var File_inout_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Backend

type Backend interface {
	GetUser(ctx context.Context, token string) (int, IAuthenticationBackendUser)
}

type Client

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

func InitHiveClient

func InitHiveClient(config *Config) *Client

func (*Client) AddBackend

func (client *Client) AddBackend(key string, backend Backend)

func (*Client) Auth

func (client *Client) Auth(handler http.Handler) http.Handler

func (*Client) AuthRequired

func (client *Client) AuthRequired(handler http.Handler) http.Handler

func (*Client) GetBackend

func (client *Client) GetBackend(key string) Backend

func (*Client) GetRepository

func (client *Client) GetRepository() Repository

func (*Client) GetToken

func (client *Client) GetToken(authorizationHeader string) (string, string)

func (*Client) GetUserFromContext

func (client *Client) GetUserFromContext(ctx context.Context) IAuthenticationBackendUser

func (*Client) Login

func (client *Client) Login(ctx context.Context, r *http.Request) (int, IAuthenticationBackendUser)

func (*Client) RemoveBackend

func (client *Client) RemoveBackend(key string) Backend

func (*Client) SetUserToContext

func (client *Client) SetUserToContext(ctx context.Context, user IAuthenticationBackendUser) context.Context

func (*Client) Stop

func (client *Client) Stop()

type Config

type Config struct {
	AuthorizationHeader         string
	Backends                    map[string]Backend
	HiveAPI                     string
	SubscriptionTopic           string
	ServiceName                 string
	NSQLookupAddress            string
	AuthenticatedUserContextKey string
}

type GetSecretResponseV1

type GetSecretResponseV1 struct {
	Data *SecretResponse `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSecretResponseV1) Descriptor deprecated

func (*GetSecretResponseV1) Descriptor() ([]byte, []int)

Deprecated: Use GetSecretResponseV1.ProtoReflect.Descriptor instead.

func (*GetSecretResponseV1) GetData

func (x *GetSecretResponseV1) GetData() *SecretResponse

func (*GetSecretResponseV1) ProtoMessage

func (*GetSecretResponseV1) ProtoMessage()

func (*GetSecretResponseV1) ProtoReflect

func (x *GetSecretResponseV1) ProtoReflect() protoreflect.Message

func (*GetSecretResponseV1) Reset

func (x *GetSecretResponseV1) Reset()

func (*GetSecretResponseV1) String

func (x *GetSecretResponseV1) String() string

type IAuthenticationBackendUser

type IAuthenticationBackendUser interface {
	GetIsAdmin() bool
	GetRoles() []string
	GetUserID() uuid.UUID
}

type JWTBackend

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

func InitJWTBackend

func InitJWTBackend(repository *Repository) *JWTBackend

func (JWTBackend) DecodeAccessToken

func (backend JWTBackend) DecodeAccessToken(_ context.Context, tokenValue string, secret uuid.UUID) (int, *JWTUser)

func (JWTBackend) DecodeAccessTokenWithoutValidation

func (backend JWTBackend) DecodeAccessTokenWithoutValidation(_ context.Context, tokenValue string) (int, *JWTUser)

func (JWTBackend) GetUser

func (backend JWTBackend) GetUser(ctx context.Context, token string) (int, IAuthenticationBackendUser)

type JWTUser

type JWTUser struct {
	jwt.StandardClaims
	IsAdmin  bool      `json:"isAdmin"`
	Roles    []string  `json:"roles"`
	UserID   uuid.UUID `json:"userID"`
	SecretID uuid.UUID `json:"secretID"`
}

func (JWTUser) GetIsAdmin

func (user JWTUser) GetIsAdmin() bool

func (JWTUser) GetRoles

func (user JWTUser) GetRoles() []string

func (JWTUser) GetUserID

func (user JWTUser) GetUserID() uuid.UUID

type Repository

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

func InitRepository

func InitRepository(hiveAPI string) *Repository

func (Repository) GetSecret

func (repository Repository) GetSecret(id uuid.UUID) *Secret

func (Repository) SetSecret

func (repository Repository) SetSecret(secret *Secret)

type Secret

type Secret struct {
	Id      uuid.UUID
	Created int64
	Value   uuid.UUID
}

type SecretCreatedV1

type SecretCreatedV1 struct {
	Id      []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Created int64  `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"`
	Value   []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*SecretCreatedV1) Descriptor deprecated

func (*SecretCreatedV1) Descriptor() ([]byte, []int)

Deprecated: Use SecretCreatedV1.ProtoReflect.Descriptor instead.

func (*SecretCreatedV1) GetCreated

func (x *SecretCreatedV1) GetCreated() int64

func (*SecretCreatedV1) GetId

func (x *SecretCreatedV1) GetId() []byte

func (*SecretCreatedV1) GetValue

func (x *SecretCreatedV1) GetValue() []byte

func (*SecretCreatedV1) ProtoMessage

func (*SecretCreatedV1) ProtoMessage()

func (*SecretCreatedV1) ProtoReflect

func (x *SecretCreatedV1) ProtoReflect() protoreflect.Message

func (*SecretCreatedV1) Reset

func (x *SecretCreatedV1) Reset()

func (*SecretCreatedV1) String

func (x *SecretCreatedV1) String() string

type SecretResponse

type SecretResponse struct {
	Id      []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Created int64  `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"`
	Value   []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*SecretResponse) Descriptor deprecated

func (*SecretResponse) Descriptor() ([]byte, []int)

Deprecated: Use SecretResponse.ProtoReflect.Descriptor instead.

func (*SecretResponse) GetCreated

func (x *SecretResponse) GetCreated() int64

func (*SecretResponse) GetId

func (x *SecretResponse) GetId() []byte

func (*SecretResponse) GetValue

func (x *SecretResponse) GetValue() []byte

func (*SecretResponse) ProtoMessage

func (*SecretResponse) ProtoMessage()

func (*SecretResponse) ProtoReflect

func (x *SecretResponse) ProtoReflect() protoreflect.Message

func (*SecretResponse) Reset

func (x *SecretResponse) Reset()

func (*SecretResponse) String

func (x *SecretResponse) String() string

type SecretsRepository

type SecretsRepository interface {
	GetSecret(id uuid.UUID) *Secret
}

type Subscription

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

func InitHiveSubscription

func InitHiveSubscription(serviceName string, topic string, nsqLookupAddress string, repository *Repository) *Subscription

func (*Subscription) HandleMessage

func (subscription *Subscription) HandleMessage(message *nsq.Message) error

func (*Subscription) Stop

func (subscription *Subscription) Stop()

Jump to

Keyboard shortcuts

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