3
0

small refactor rbac interfaces

This commit is contained in:
Tit Petric 2018-07-01 00:10:26 +02:00
parent f67657f72d
commit 725738f05a
2 changed files with 54 additions and 54 deletions

View File

@ -1,7 +1,8 @@
package rbac package rbac
type (
// Permissions is a stateful object // Permissions is a stateful object
type Permissions interface /* for Session, User, Roles, Resource */ { Permissions interface /* for Session, User, Roles, Resource */ {
// Scoped for [Resource] // Scoped for [Resource]
Grant(permission string) error Grant(permission string) error
Revoke(permission string) error Revoke(permission string) error
@ -12,7 +13,7 @@ type Permissions interface /* for Session, User, Roles, Resource */ {
} }
// Roles is a stateful object // Roles is a stateful object
type Roles interface /* for Session, User */ { Roles interface /* for Session, User */ {
// Scoped to User // Scoped to User
Add(role string) error Add(role string) error
Delete(role string) error Delete(role string) error
@ -30,7 +31,7 @@ type Roles interface /* for Session, User */ {
} }
// Session object holds session state (Create, Load) // Session object holds session state (Create, Load)
type Session interface { Session interface {
// Unscoped functions // Unscoped functions
Create(userID string, roles ...string) error Create(userID string, roles ...string) error
Load(sessionID string) error Load(sessionID string) error
@ -45,7 +46,7 @@ type Session interface {
} }
// Resource is a static object // Resource is a static object
type Resource interface { Resource interface {
Load(resource string) error Load(resource string) error
Create(resource string) error Create(resource string) error
Delete(resource string) error Delete(resource string) error
@ -55,7 +56,7 @@ type Resource interface {
} }
// Users is a static object // Users is a static object
type User interface { User interface {
Load(user string) error Load(user string) error
Create(user string) error Create(user string) error
Delete(user string) error Delete(user string) error
@ -64,3 +65,4 @@ type User interface {
Roles(user string) Roles Roles(user string) Roles
Permissions(user string) Permissions Permissions(user string) Permissions
} }
)

View File

@ -1,2 +0,0 @@
#!/bin/bash
echo $(echo $(sed -n 's/^\(type \|\s*\)\([A-Z][^[:space:]]*\) interface .*/\2/p' "interfaces.go") | tr ' ' ',')