auth

package
v0.0.0-...-4168d8d Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Issuer string = "mainflux"

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(plain, hashed string) error

CheckPassword tries to determine whether or not the submitted password matches the one stored (and hashed) during registration. An error will be used to indicate an invalid password.

func CreateKey

func CreateKey(subject string) (string, error)

CreateKey creates a JSON Web Token with a given subject.

func DecodeJwt

func DecodeJwt(key string) (*jwt.StandardClaims, error)

DecodeJWT decodes jwt token

func InitLogger

func InitLogger(l *zap.Logger)

InitLogger - Init zap Logger

func InitMongoRepository

func InitMongoRepository(r *mongo.Repository)

InitMongoRepository - Init Mongo DB

func SetSecretKey

func SetSecretKey(key string)

SetSecretKey sets the secret key that will be used for decoding and encoding tokens. If not invoked, a default key will be used instead.

func StartHTTPServer

func StartHTTPServer(host string, port int, errChan chan error)

Types

type AuthError

type AuthError struct {
	Code    int
	Message string
}

AuthError is used as a wrapper for all types of errors originated throughout the service. Code will be used as API response status.

func (*AuthError) Error

func (e *AuthError) Error() string

type Config

type Config struct {
	Port int
	Host string
}
var AuthCfg Config

func InitConfig

func InitConfig(host string, port int) Config

type User

type User struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

func CreateUser

func CreateUser(username, password string) (User, error)

CreateUser creates new user account based on provided username and password. The account is assigned with one master key - a key with all permissions on all owned resources regardless of their type. Provided password in encrypted using bcrypt algorithm.

Jump to

Keyboard shortcuts

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