Simple authentication helper for GO.
This library was created to reduce the amount of boilerplate code I had to write to support authentication in my applications. It serves as a basic skeleton for an authentication system. The system is designed to facilitate the use of user permissions which represented as dot delimited strings.
var userToCreate User
userToCreate.Username = "testuser"
userToCreate.FirstName = "Test"
userToCreate.LastName = "User"
userToCreate.Email = "[email protected]"
userToCreate.PhoneNumber = "1234567890"
userToCreate.Permissions = []Permission{{Permission: "test.pass"}}
userToCreate, err := authProvider.CreateUser(userToCreate)
if err != nil {
t.Fatal(err.Error())
}
user, _ := authProvider.GetUser("testuser")
hasPerm, err := authProvider.CheckPermission(user.ID, "test.pass")
if err != nil {
//Handle error
}
if hasPerm {
//User has this permission
}
Please check auth_test.go for more examples