Documentation ¶
Index ¶
- func InsertTokenIntoRedis(User Person, token string, redisClient *redis.Client) string
- func LoginUserCoreHTTP(username, password string, mongoClient *mgo.Session) string
- func ParseAuthCredentialFromHeaders(auth []byte) (string, string)
- func PasswordValidation(password string) bool
- func RegisterUserCoreHTTP(username, password string, mongoClient *mgo.Session) string
- func TokenValidation(token string) bool
- func UsernameValidation(username string) bool
- func ValidateCredentials(user string, pass string) bool
- func VerifyCookieFromRedisCoreHTTP(user, token string, redisClient *redis.Client) string
- type City
- type Info
- type Person
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertTokenIntoRedis ¶
InsertTokenIntoRedis is delegated to store the token of the customer into Redis. After that a customer have logged in, the token assigned as a cookie is stored into Redis (used as a Cache), in order to validate every request without query MongoDB.
func LoginUserCoreHTTP ¶
LoginUserCoreHTTP 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 PasswordValidation ¶
PasswordValidation execute few check on the password in input
func RegisterUserCoreHTTP ¶
RegisterUserCoreHTTP 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 TokenValidation ¶
TokenValidation execute few check on the token in input
func UsernameValidation ¶
UsernameValidation execute few check on the username in input
func ValidateCredentials ¶
ValidateCredentials is wrapper for the multiple method for validate the input parameters
func VerifyCookieFromRedisCoreHTTP ¶
VerifyCookieFromRedisCoreHTTP 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 ¶
type City ¶
type City struct { Name string `bson:"Name,omitempty"` // Bergamo Town string `bson:"Town,omitempty"` // Verdello ZipCode int `bson:"ZipCode,omitempty"` }
City save the location status of the customer
type Info ¶
type Info struct { Type string `bson:"Type,omitempty"` // IT Specialist Skills []string `bson:"Skills,omitempty"` // Java, Spring, Golang Years int `bson:"Years,omitempty"` City City `bson:"City,omitempty"` }
Info Used for track user skill/experience/role
type Person ¶
type Person struct { ID bson.ObjectId `bson:"_id,omitempty" json:"_id,omitempty"` Username string `bson:"Username,omitempty" json:"Username,omitempty"` Password string `bson:"Password,omitempty" json:"Password,omitempty"` Name string `bson:"Name,omitempty" json:"Name,omitempty"` Surname string `bson:"Surname,omitempty"` Birthday time.Time `bson:"Birthday,omitempty"` // time.Date(2014, time.November, 5, 0, 0, 0, 0, time.UTC) Cellphone string `bson:"Cellphone,omitempty"` Phone string `bson:"Phone,omitempty"` Addresses []Info `bson:"Addresses,omitempty"` Mail string `bson:"Mail,omitempty" json:"Mail,omitempty"` WorkMail string `bson:"WorkMail,omitempty"` }
Person structure of a customer for save it into the DB during registration phase.