Skip to content
/ go-auth Public

Simple authentication support library for Go applications

License

Notifications You must be signed in to change notification settings

twa16/go-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Auth

Simple authentication helper for GO.

GoDoc

Overview

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.

Examples

Creating a User
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())
}
Check is a user has a permission
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

About

Simple authentication support library for Go applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages