auth

package
v0.0.0-...-b012a22 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamInterceptor

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

StreamInterceptor is the stream middleware that checks authentication

func UnaryInterceptor

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

UnaryInterceptor is the unary middleware that checks authentication

Types

type Session

type Session struct {
	Token string
}

Session contains a session token

func Login

func Login(username, password, privateKeyFile string) (Session, error)

Login takes a username and password, authenticates the user, and returns a session object

type User

type User struct {
	ID             int64  `db:"id" json:"id"`
	Username       string `db:"username" json:"username"`
	Password       string `json:"password"`
	HashedPassword []byte `db:"hashed_password"`
}

User represents a single system user.

func CreateUser

func CreateUser(u *User) (*User, error)

CreateUser adds a new user record to the database and populates the new ID.

func GetUserByUsername

func GetUserByUsername(username string) (User, error)

GetUserByUsername returns a persisted user given a username.

Jump to

Keyboard shortcuts

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