auth

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PermissionNone = iota
	PermissionR
	PermissionW
	PermissionRW
)
View Source
const ClientIDMetadataKey = "client_id"
View Source
const ClientIDMetadataValueAdmin = "immuadmin"
View Source
const PermissionAdmin = 255

Variables

View Source
var AdminUserExists func(ctx context.Context) (bool, error)
View Source
var AdminUsername = "immu"
View Source
var AuthEnabled bool

TODO OGG: in the future, after other types of auth will be implemented, this will have to be of Kind (see above) type instead of bool:

View Source
var CreateAdminUser func(ctx context.Context) (string, string, error)
View Source
var ErrServerAuthDisabled = status.Error(
	codes.Unavailable, "authentication is disabled on server")
View Source
var IsAdminUser func(ctx context.Context, username []byte) (bool, error)
View Source
var IsValidUsername = regexp.MustCompile(`^[a-zA-Z0-9_]+$`).MatchString
View Source
var PasswordRequirementsMsg = fmt.Sprintf(
	"password must have between %d and %d letters, digits and special characters "+
		"of which at least 1 uppercase letter, 1 digit and 1 special character",
	minPasswordLen,
	maxPasswordLen,
)
View Source
var UpdateMetrics func(context.Context)

Functions

func ClientUnaryInterceptor

func ClientUnaryInterceptor(token string) func(context.Context, string, interface{}, interface{}, *grpc.ClientConn, grpc.UnaryInvoker, ...grpc.CallOption) error

func ComparePasswords

func ComparePasswords(hashedPassword []byte, plainPassword []byte) error

func DropTokenKeys

func DropTokenKeys(username string)

DropTokenKeys ...

func GenerateKeys

func GenerateKeys(username string) error

GenerateKeys ...

func GeneratePassword

func GeneratePassword() string

GeneratePassword generates a random ASCII string with at least one digit and one special character

func GenerateToken

func GenerateToken(user User) (string, error)

GenerateToken ...

func HasAuth

func HasAuth(method string) bool

func HasPermissionForMethod

func HasPermissionForMethod(userPermission byte, method string) bool

func HashAndSaltPassword

func HashAndSaltPassword(plainPassword string) ([]byte, error)

func IsAdminClient

func IsAdminClient(ctx context.Context) bool

func IsStrongPassword

func IsStrongPassword(password string) error

func ServerStreamInterceptor

func ServerStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func ServerUnaryInterceptor

func ServerUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

Types

type ErrFirstAdminLogin

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

func (*ErrFirstAdminLogin) Error

func (e *ErrFirstAdminLogin) Error() string

func (*ErrFirstAdminLogin) Matches

func (e *ErrFirstAdminLogin) Matches(err error) (string, bool)

func (*ErrFirstAdminLogin) With

func (e *ErrFirstAdminLogin) With(username string, password string) *ErrFirstAdminLogin

type JSONToken

type JSONToken struct {
	Username    string
	Permissions byte
	Expiration  time.Time
}

JSONToken ...

type Kind

type Kind uint32
const (
	KindNone Kind = iota
	KindPassword
	KindCryptoSig
)

type TokenAuth

type TokenAuth struct {
	Token string
}

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error)

func (TokenAuth) RequireTransportSecurity

func (TokenAuth) RequireTransportSecurity() bool

type User

type User struct {
	Username       string `json:"username"`
	HashedPassword []byte `json:"-"`
	Permissions    byte   `json:"permissions"`
}

User ...

func (*User) ComparePasswords

func (u *User) ComparePasswords(plainPassword []byte) error

ComparePasswords ...

func (*User) GenerateAndSetPassword

func (u *User) GenerateAndSetPassword() (string, error)

GenerateAndSetPassword ...

func (*User) SetPassword

func (u *User) SetPassword(hashedPassword []byte)

type WrappedClientStream

type WrappedClientStream struct {
	grpc.ClientStream
}

func (*WrappedClientStream) RecvMsg

func (w *WrappedClientStream) RecvMsg(m interface{}) error

func (*WrappedClientStream) SendMsg

func (w *WrappedClientStream) SendMsg(m interface{}) error

type WrappedServerStream

type WrappedServerStream struct {
	grpc.ServerStream
}

func (*WrappedServerStream) RecvMsg

func (w *WrappedServerStream) RecvMsg(m interface{}) error

func (*WrappedServerStream) SendMsg

func (w *WrappedServerStream) SendMsg(m interface{}) error

Jump to

Keyboard shortcuts

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