Documentation ¶
Overview ¶
Package sec is the security implementation used by the CPM application. Key function is to issue tokens and validate them against an RBAC based schema defined and maintained within CPM.
Index ¶
- func DBAddRole(dbConn *sql.DB, role Role) error
- func DBAddRolePerm(dbConn *sql.DB, role string, perm string) error
- func DBAddSession(dbConn *sql.DB, uuid string, id string) error
- func DBAddUser(dbConn *sql.DB, user User) error
- func DBAddUserRole(dbConn *sql.DB, user string, role string) error
- func DBDeleteRole(dbConn *sql.DB, name string) error
- func DBDeleteSession(dbConn *sql.DB, uuid string) error
- func DBDeleteUser(dbConn *sql.DB, name string) error
- func DBUpdatePassword(dbConn *sql.DB, username string, password string) error
- func DBUpdateRole(dbConn *sql.DB, role Role) error
- func DBUpdateUser(dbConn *sql.DB, user User) error
- func DecryptPassword(encodedHexPassword string) (string, error)
- func EncryptPassword(inputPassword string) (string, error)
- func LogPermissions(perms map[string]Permission)
- func LogUser(user User)
- type CustomSec
- func (d CustomSec) AddRole(dbConn *sql.DB, role Role) error
- func (d CustomSec) AddUser(dbConn *sql.DB, user User) error
- func (d CustomSec) Authorize(dbConn *sql.DB, token string, action string) error
- func (d CustomSec) ChangePassword(dbConn *sql.DB, username string, newpass string) error
- func (d CustomSec) CompareUserToToken(string, string) (bool, error)
- func (d CustomSec) DeleteRole(dbConn *sql.DB, name string) error
- func (d CustomSec) DeleteUser(dbConn *sql.DB, id string) error
- func (d CustomSec) GetAllRoles(dbConn *sql.DB) ([]Role, error)
- func (d CustomSec) GetAllUsers(dbConn *sql.DB) ([]User, error)
- func (d CustomSec) GetRole(dbConn *sql.DB, name string) (Role, error)
- func (d CustomSec) GetUser(dbConn *sql.DB, id string) (User, error)
- func (d CustomSec) LogRole(role Role)
- func (d CustomSec) LogUser(user User)
- func (d CustomSec) Login(dbConn *sql.DB, id string, psw string) (string, error)
- func (d CustomSec) Logout(dbConn *sql.DB, id string) error
- func (d CustomSec) UpdateRole(dbConn *sql.DB, role Role) error
- func (d CustomSec) UpdateUser(dbConn *sql.DB, user User) error
- type DefaultSec
- func (d DefaultSec) AddRole(dbConn *sql.DB, role Role) error
- func (d DefaultSec) AddUser(dbConn *sql.DB, user User) error
- func (d DefaultSec) Authorize(dbConn *sql.DB, token string, action string) error
- func (d DefaultSec) ChangePassword(dbConn *sql.DB, username string, newpass string) error
- func (d DefaultSec) CompareUserToToken(dbConn *sql.DB, username string, token string) (bool, error)
- func (d DefaultSec) DeleteRole(dbConn *sql.DB, name string) error
- func (d DefaultSec) DeleteUser(dbConn *sql.DB, id string) error
- func (d DefaultSec) GetAllRoles(dbConn *sql.DB) ([]Role, error)
- func (d DefaultSec) GetAllUsers(dbConn *sql.DB) ([]User, error)
- func (d DefaultSec) GetRole(dbConn *sql.DB, name string) (Role, error)
- func (d DefaultSec) GetUser(dbConn *sql.DB, id string) (User, error)
- func (d DefaultSec) LogRole(role Role)
- func (d DefaultSec) LogUser(user User)
- func (d DefaultSec) Login(dbConn *sql.DB, id string, psw string) (string, error)
- func (d DefaultSec) Logout(dbConn *sql.DB, uuid string) error
- func (d DefaultSec) UpdateRole(dbConn *sql.DB, role Role) error
- func (d DefaultSec) UpdateUser(dbConn *sql.DB, user User) error
- type Permission
- type Role
- type SecInterface
- type Session
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DBAddRolePerm ¶
DBAddRolePerm create a role to perm mapping
func DBAddSession ¶
DBAddSession create a user session
func DBAddUserRole ¶
DBAddUserRole create a user to role mapping
func DBDeleteRole ¶
DBDeleteRole delete a role by name
func DBDeleteSession ¶
DBDeleteSession remove a user session
func DBDeleteUser ¶
DBDeleteUser delete a user by userid
func DBUpdatePassword ¶
DBUpdatePassword update a user password
func DecryptPassword ¶
DecryptPassword decrypt the encrypted password returning the cleartext password
func EncryptPassword ¶
EncryptPassword encrypt a cleartext password returning the encrypted password
func LogPermissions ¶
func LogPermissions(perms map[string]Permission)
LogPermissions print to stdout a map of permissions
Types ¶
type CustomSec ¶
type CustomSec struct { }
func (CustomSec) ChangePassword ¶
func (CustomSec) CompareUserToToken ¶
type DefaultSec ¶
type DefaultSec struct { }
func (DefaultSec) AddRole ¶
func (d DefaultSec) AddRole(dbConn *sql.DB, role Role) error
AddRole add a role
func (DefaultSec) AddUser ¶
func (d DefaultSec) AddUser(dbConn *sql.DB, user User) error
AddUser create a new user object
func (DefaultSec) Authorize ¶
Authorize perform an authorization based on a security token and requested action
func (DefaultSec) ChangePassword ¶
ChangePassword change a users password
func (DefaultSec) CompareUserToToken ¶
CompareUserToToken test to see if a token matches a user id
func (DefaultSec) DeleteRole ¶
func (d DefaultSec) DeleteRole(dbConn *sql.DB, name string) error
DeleteRole delete a role by name
func (DefaultSec) DeleteUser ¶
func (d DefaultSec) DeleteUser(dbConn *sql.DB, id string) error
DeleteUser delete a user
func (DefaultSec) GetAllRoles ¶
func (d DefaultSec) GetAllRoles(dbConn *sql.DB) ([]Role, error)
GetAllRoles return a list of all roles
func (DefaultSec) GetAllUsers ¶
func (d DefaultSec) GetAllUsers(dbConn *sql.DB) ([]User, error)
GetAllUsers return a list of all users
func (DefaultSec) Login ¶
Login perform a login using a password and user id returning the security token if successful
func (DefaultSec) Logout ¶
func (d DefaultSec) Logout(dbConn *sql.DB, uuid string) error
Logout logout the user using the security token
func (DefaultSec) UpdateRole ¶
func (d DefaultSec) UpdateRole(dbConn *sql.DB, role Role) error
UpdateRole update a role
func (DefaultSec) UpdateUser ¶
func (d DefaultSec) UpdateUser(dbConn *sql.DB, user User) error
UpdateUser update the user object
type Permission ¶
func DBGetPermissions ¶
func DBGetPermissions(dbConn *sql.DB) ([]Permission, error)
DBGetPermissions get a complete list of possible permissions
type Role ¶
type Role struct { Name string Selected bool Permissions map[string]Permission UpdateDate string Token string }
type SecInterface ¶
type SecInterface interface { Authorize(*sql.DB, string, string) error Login(*sql.DB, string, string) (string, error) Logout(*sql.DB, string) error ChangePassword(*sql.DB, string, string) error CompareUserToToken(*sql.DB, string, string) (bool, error) UpdateUser(*sql.DB, User) error AddUser(*sql.DB, User) error GetUser(*sql.DB, string) (User, error) GetAllUsers(*sql.DB) ([]User, error) DeleteUser(*sql.DB, string) error UpdateRole(*sql.DB, Role) error AddRole(*sql.DB, Role) error DeleteRole(*sql.DB, string) error GetAllRoles(*sql.DB) ([]Role, error) GetRole(*sql.DB, string) (Role, error) LogRole(Role) LogUser(User) }