authutils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCookie

func CreateCookie(key string, value string, expire int) *fasthttp.Cookie

CreateCookie Method that return a cookie valorized as input (GoLog-Token as key)

func DeleteUserHTTPCore

func DeleteUserHTTPCore(user, password, token string, redisClient *redis.Client) error

DeleteUserHTTPCore is delegated to remove the given username from the DB

func LoginUserHTTPCore

func LoginUserHTTPCore(username, password string, redisClient *redis.Client) error

LoginUserHTTPCore is delegated to manage the "core process" of authentication. It use the username in input for retrieve the customer data from MongoDB. If the data is found, then the password in input will be compared with the one retrieved from the database

func ParseAuthCredentialFromHeaders

func ParseAuthCredentialFromHeaders(auth []byte) (string, string)

ParseAuthCredentialFromHeaders is delegated to extract the username and the password from the BasicAuth header provided by the request In case of error will return two emtpy string; in case of success will return (username,password)

func ParseAuthCredentialsFromRequestBody

func ParseAuthCredentialsFromRequestBody(ctx *fasthttp.RequestCtx) (string, string)

ParseAuthCredentialsFromRequestBody is delegated to extract the username and the password from the request body

func PasswordValidation

func PasswordValidation(password string) bool

PasswordValidation execute few check on the password in input

func RegisterUserHTTPCore

func RegisterUserHTTPCore(username, password string, redisClient *redis.Client) error

RegisterUserHTTPCore is delegated to register the credential of the user into the Redis database. It estabilish the connection to MongoDB with a specialized function, then it create an user with the input data. After that, it ask to a delegated function to insert the data into Redis.

func ValidateCredentials

func ValidateCredentials(user string, pass string) bool

ValidateCredentials is wrapper for the multiple method for validate the input parameters

func ValidateToken

func ValidateToken(token string) bool

ValidateToken execute few check on the token in input

func ValidateUsername

func ValidateUsername(username string) bool

ValidateUsername execute few check on the username in input

func VerifyCookieFromRedisHTTPCore

func VerifyCookieFromRedisHTTPCore(user, token string, redisClient *redis.Client) error

VerifyCookieFromRedisHTTPCore is delegated to verify if the cookie of the customer is present on the DB (aka is logged). This method have only to verify if the token provided by the customer that use the API is present on RedisDB. In first instance it try to validate the input data. Then will continue connecting to Redis in order to retrieve the token of the customer. If the token is found, the customer is authorized to continue.

Types

This section is empty.

Jump to

Keyboard shortcuts

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