Documentation
¶
Index ¶
- Constants
- Variables
- func ClientStreamInterceptor(token string) ...
- func ClientUnaryInterceptor(token string) ...
- func ComparePasswords(hashedPassword []byte, plainPassword []byte) error
- func GenerateKeys() error
- func GenerateOrLoadKeys() error
- func GeneratePassword() string
- func GenerateToken(user User) (string, error)
- func HasAuth(method string) bool
- func HashAndSaltPassword(plainPassword string) ([]byte, error)
- func IsAdminClient(ctx context.Context) bool
- func IsStrongPassword(password string) error
- func ServerStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func ServerUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- type ErrFirstAdminLogin
- type JSONToken
- type Kind
- type TokenAuth
- type User
- type WrappedClientStream
- type WrappedServerStream
Constants ¶
View Source
const ClientIDMetadataKey = "client_id"
View Source
const ClientIDMetadataValueAdmin = "immuadmin"
Variables ¶
View Source
var AdminUserExists func(ctx context.Context) bool
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 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 ClientStreamInterceptor ¶
func ClientStreamInterceptor(token string) func(context.Context, *grpc.StreamDesc, *grpc.ClientConn, string, grpc.Streamer, ...grpc.CallOption) (grpc.ClientStream, error)
func ClientUnaryInterceptor ¶
func ClientUnaryInterceptor(token string) func(context.Context, string, interface{}, interface{}, *grpc.ClientConn, grpc.UnaryInvoker, ...grpc.CallOption) error
func ComparePasswords ¶
func GeneratePassword ¶
func GeneratePassword() string
GeneratePassword generates a random ASCII string with at least one digit and one special character
func HashAndSaltPassword ¶
func IsAdminClient ¶
func IsStrongPassword ¶
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) With ¶
func (e *ErrFirstAdminLogin) With(username string, password string) *ErrFirstAdminLogin
type TokenAuth ¶
type TokenAuth struct {
Token string
}
func (TokenAuth) GetRequestMetadata ¶
func (TokenAuth) RequireTransportSecurity ¶
type User ¶
type User struct { Username string `json:"username"` HashedPassword []byte `json:"-"` Admin bool `json:"admin"` }
User ...
func (*User) ComparePasswords ¶
ComparePasswords ...
func (*User) GenerateAndSetPassword ¶
GenerateAndSetPassword ...
func (*User) SetPassword ¶
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
Click to show internal directories.
Click to hide internal directories.