iam

package
v0.0.0-...-ac0b2cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ActionUserList           = "iam:user.list"
	ActionUserRead           = "iam:user.read"
	ActionUserLock           = "iam:user.lock"
	ActionUserWrite          = "iam:user.write"
	ActionUserChangePassword = "iam:user.change-password"
	ActionUserConsole        = "iam:user.console"
	ActionGroupRead          = "iam:group.list"
	ActionGroupWrite         = "iam:group.write"
)

Actions defined by the IAM service

Variables

View Source
var Actions = map[string]string{
	ActionUserList:           "List available users",
	ActionUserRead:           "Read user data",
	ActionUserLock:           "Lock or unlock a user account",
	ActionUserWrite:          "Create or delete a user",
	ActionUserChangePassword: "Reset user password",
	ActionUserConsole:        "Use the user adminstration console",
	ActionGroupRead:          "Read available groups",
	ActionGroupWrite:         "Create and update existing groups",
}

Actions holds all registered actions and a description for each of them

Functions

func GroupURN

func GroupURN(groupID uint) string

GroupURN constructs a fully qualified group URN from groupID

func IDFromURN

func IDFromURN(urn string) string

IDFromURN returns the ID of a user or group from it's URN

func UserURN

func UserURN(accountID string) string

UserURN constructs a fully qualified user URN from accountID

Types

type Group

type Group struct {
	ID           uint    `json:"id" gorm:"primary_key"`
	Name         string  `json:"name"`
	Description  string  `json:"description"`
	ResourceName string  `sql:"-" json:"urn"`
	Users        []*User `json:"-" gorm:"many2many:group_users"`
}

Group represents a group in IAM

func (*Group) Owner

func (g *Group) Owner() string

Owner returns the owner of the resource Groups itself do not have owners so an empty string is returned. It implements the resource.Resource interface

func (*Group) URN

func (g *Group) URN() string

URN returns the unique resource name of g and implements resource.Resource

type User

type User struct {
	AccountID   string     `json:"accountID" gorm:"primary_key"`
	Username    string     `json:"username"`
	Firstname   string     `json:"firstname"`
	Lastname    string     `json:"lastname"`
	MailAddress string     `json:"email"`
	PhoneNumber string     `json:"phone"`
	Job         string     `json:"job"`
	Street      string     `json:"street"`
	City        string     `json:"city"`
	CityCode    string     `json:"cityCode"`
	Birthday    *time.Time `json:"birthday,omitempty"`

	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt"`

	Groups []*Group `json:"-" gorm:"many2many:group_users"`

	ResourceName string `sql:"-" json:"urn"`    // will be calculated by URN() before marshaling to JSON
	Locked       *bool  `json:"locked" sql:"-"` // will be loaded from the authn-server

}

User is the user model exposed via a V1 API It also serves as a micro resource

func (*User) Owner

func (u *User) Owner() string

Owner returns the owner of the resource Users itself do not have owners so an empty string is returned. It implements the resource.Resource interface

func (*User) URN

func (u *User) URN() string

URN returns the unique resource name of u and implements resource.Resource

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL