Documentation ¶
Index ¶
- func CreateCookie(key string, value string, expire int) *fasthttp.Cookie
- func DeleteUserHTTPCore(user, password, token string, redisClient *redis.Client) error
- func LoginUserHTTPCore(username, password string, redisClient *redis.Client) error
- func ParseAuthCredentialFromHeaders(auth []byte) (string, string)
- func ParseAuthCredentialsFromRequestBody(ctx *fasthttp.RequestCtx) (string, string)
- func PasswordValidation(password string) bool
- func RegisterUserHTTPCore(username, password string, redisClient *redis.Client) error
- func ValidateCredentials(user string, pass string) bool
- func ValidateToken(token string) bool
- func ValidateUsername(username string) bool
- func VerifyCookieFromRedisHTTPCore(user, token string, redisClient *redis.Client) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCookie ¶
CreateCookie Method that return a cookie valorized as input (GoLog-Token as key)
func DeleteUserHTTPCore ¶
DeleteUserHTTPCore is delegated to remove the given username from the DB
func LoginUserHTTPCore ¶
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 ¶
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 ¶
PasswordValidation execute few check on the password in input
func RegisterUserHTTPCore ¶
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 ¶
ValidateCredentials is wrapper for the multiple method for validate the input parameters
func ValidateToken ¶
ValidateToken execute few check on the token in input
func ValidateUsername ¶
ValidateUsername execute few check on the username in input
func VerifyCookieFromRedisHTTPCore ¶
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.