Documentation
¶
Index ¶
- Variables
- type Privilege
- type Role
- type User
- func (u *User) CanGrant(role *Role) bool
- func (u *User) CanModifyUser(user *User) bool
- func (u *User) Delete() error
- func (u *User) Deny(role *Role)
- func (u *User) Grant(role *Role)
- func (u *User) HasRole(role *Role) bool
- func (u *User) IsAdmin() bool
- func (u *User) PermittedTo(priv *Privilege) bool
- func (u *User) Roles() []*Role
- func (u *User) Save() error
Constants ¶
This section is empty.
Variables ¶
var ( // Titles ListTitles = newPrivilege(RoleAny) ModifyTitles = newPrivilege(RoleTitleManager) // Add or delete MARC org codes ManageMOCs = newPrivilege(RoleMOCManager) // Workflow ViewMetadataWorkflow = newPrivilege(RoleIssueCurator, RoleIssueReviewer) EnterIssueMetadata = newPrivilege(RoleIssueCurator) ReviewIssueMetadata = newPrivilege(RoleIssueReviewer) ReviewOwnMetadata = newPrivilege() // User management ListUsers = newPrivilege(RoleUserManager) ModifyUsers = newPrivilege(RoleUserManager) // Uploaded issue viewing & queueing ViewUploadedIssues = newPrivilege(RoleWorkflowManager) ModifyUploadedIssues = newPrivilege(RoleWorkflowManager) // View the SFTP credentials for a title ViewTitleSFTPCredentials = newPrivilege(RoleTitleManager) // Search for issues across all locations - this could really be more open, // but I don't see it being necessary for anybody but workflow managers at // the moment SearchIssues = newPrivilege(RoleWorkflowManager) // Admins only ModifyValidatedLCCNs = newPrivilege() ModifyTitleSFTP = newPrivilege() ListAuditLogs = newPrivilege() )
This is our full, hard-coded list of valid privileges
var ( RoleAny = newRole("-any-", "N/A") RoleAdmin = newRole("admin", `No restrictions. These users can modify data not meant for modification outside of initial setup and data repair situations, such as sftp user/password, LCCNs which have already been validated, etc.`) RoleTitleManager = newRole("title manager", `Has access to add and change newspaper titles, including the ability to view the sftp authorization information`) RoleIssueCurator = newRole("issue curator", `Can modify issue metadata and push issues to the review queue`) RoleIssueReviewer = newRole("issue reviewer", `Can modify issue metadata, push issues to the review queue, and mark issues as reviewed`) RoleUserManager = newRole("user manager", `Can add, edit, and delete users. User managers can assign any rights to others which have been assigned to them.`) RoleMOCManager = newRole("marc org code manager", "Has access to add new MARC Org Codes") RoleWorkflowManager = newRole("workflow manager", "Can queue SFTP and scanned issues for processing") )
Hard-coded list of roles
var AssignableRoles = []*Role{ RoleAdmin, RoleTitleManager, RoleIssueCurator, RoleIssueReviewer, RoleUserManager, RoleMOCManager, RoleWorkflowManager, }
AssignableRoles is a list of roles which can be assigned to a user
var EmptyUser = &User{Login: "N/A", Guest: true}
EmptyUser gives us a way to avoid returning a nil *User while still being able to detect a user not being found. Also lets us use any User functions without risking a panic.
var Privileges []*Privilege
Privileges holds the full list of valid privileges for enumeration
Functions ¶
This section is empty.
Types ¶
type Privilege ¶
type Privilege struct {
// contains filtered or unexported fields
}
A Privilege is a single action a user may be able to take
func (*Privilege) AllowedByAny ¶
AllowedByAny returns true if any of the roles can access this privilege
type Role ¶
A Role defines a grouping of privileges
func (*Role) Privileges ¶
Privileges returns which privileges this role has based on our hard-coded lists
type User ¶
type User struct { ID int `sql:",primary"` Login string `sql:",noupdate"` RolesString string `sql:"roles"` Guest bool `sql:"-"` IP string `sql:"-"` // contains filtered or unexported fields }
User identifies a person who has logged in via Apache's auth
func FindByLogin ¶
FindByLogin looks for a user whose login name is the given string
func (*User) CanModifyUser ¶
CanModifyUser tells us if u can modify the passed-in user
func (*User) Grant ¶
Grant adds the given role to this user's list of roles if it hasn't already been set
func (*User) PermittedTo ¶
PermittedTo returns true if this user has priv in his privilege list