group

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package group offers capabilities for grouping subjects together, making policy management easier.

Index

Constants

View Source
const (
	GroupsResource = "rn:hydra:warden:groups"
	GroupResource  = "rn:hydra:warden:groups:%s"
	Scope          = "hydra.warden.groups"
)
View Source
const (
	GroupsHandlerPath = "/warden/groups"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// ID is the groups id.
	ID string `json:"id"`

	// Members is who belongs to the group.
	Members []string `json:"members"`
}

Group represents a warden group

swagger:model group

type HTTPManager

type HTTPManager struct {
	Client   *http.Client
	Endpoint *url.URL
	Dry      bool
}

func (*HTTPManager) AddGroupMembers

func (m *HTTPManager) AddGroupMembers(group string, members []string) error

func (*HTTPManager) CreateGroup

func (m *HTTPManager) CreateGroup(g *Group) error

func (*HTTPManager) DeleteGroup

func (m *HTTPManager) DeleteGroup(id string) error

func (*HTTPManager) FindGroupNames

func (m *HTTPManager) FindGroupNames(subject string) ([]string, error)

func (*HTTPManager) GetGroup

func (m *HTTPManager) GetGroup(id string) (*Group, error)

func (*HTTPManager) RemoveGroupMembers

func (m *HTTPManager) RemoveGroupMembers(group string, members []string) error

type Handler

type Handler struct {
	Manager Manager
	H       herodot.Writer
	W       firewall.Firewall
}

func (*Handler) AddGroupMembers

func (h *Handler) AddGroupMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

swagger:route POST /warden/groups/{id} warden groups addMembersToGroup

Add members to a group

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups:<id>"],
  "actions": ["members.add"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     204
     401: genericError
     403: genericError
     500: genericError

func (*Handler) CreateGroup

func (h *Handler) CreateGroup(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

swagger:route POST /warden/groups warden groups createGroup

Create a group

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups"],
  "actions": ["create"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     201: groupResponse
     401: genericError
     403: genericError
     500: genericError

func (*Handler) DeleteGroup

func (h *Handler) DeleteGroup(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

swagger:route DELETE /warden/groups/{id} warden groups deleteGroup

Delete a group by id

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups:<id>"],
  "actions": ["delete"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     204
     401: genericError
     403: genericError
     500: genericError

func (*Handler) FindGroupNames

func (h *Handler) FindGroupNames(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

swagger:route GET /warden/groups warden groups findGroupsByMember

Find group IDs by member

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups:<member>"],
  "actions": ["get"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     200: findGroupsByMemberResponse
     401: genericError
     403: genericError
     500: genericError

func (*Handler) GetGroup

func (h *Handler) GetGroup(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

swagger:route GET /warden/groups/{id} warden groups getGroup

Get a group by id

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups:<id>"],
  "actions": ["create"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     201: groupResponse
     401: genericError
     403: genericError
     500: genericError

func (*Handler) RemoveGroupMembers

func (h *Handler) RemoveGroupMembers(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

swagger:route DELETE /warden/groups/{id} warden groups removeMembersFromGroup

Remove members from a group

The subject making the request needs to be assigned to a policy containing:

```
{
  "resources": ["rn:hydra:warden:groups:<id>"],
  "actions": ["members.remove"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.groups

   Responses:
     204
     401: genericError
     403: genericError
     500: genericError

func (*Handler) SetRoutes

func (h *Handler) SetRoutes(r *httprouter.Router)

type Manager

type Manager interface {
	CreateGroup(*Group) error
	GetGroup(id string) (*Group, error)
	DeleteGroup(id string) error

	AddGroupMembers(group string, members []string) error
	RemoveGroupMembers(group string, members []string) error

	FindGroupNames(subject string) ([]string, error)
}

type MemoryManager

type MemoryManager struct {
	Groups map[string]Group
	sync.RWMutex
}

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) AddGroupMembers

func (m *MemoryManager) AddGroupMembers(group string, subjects []string) error

func (*MemoryManager) CreateGroup

func (m *MemoryManager) CreateGroup(g *Group) error

func (*MemoryManager) DeleteGroup

func (m *MemoryManager) DeleteGroup(id string) error

func (*MemoryManager) FindGroupNames

func (m *MemoryManager) FindGroupNames(subject string) ([]string, error)

func (*MemoryManager) GetGroup

func (m *MemoryManager) GetGroup(id string) (*Group, error)

func (*MemoryManager) RemoveGroupMembers

func (m *MemoryManager) RemoveGroupMembers(group string, subjects []string) error

type SQLManager

type SQLManager struct {
	DB *sqlx.DB
}

func (*SQLManager) AddGroupMembers

func (m *SQLManager) AddGroupMembers(group string, subjects []string) error

func (*SQLManager) CreateGroup

func (m *SQLManager) CreateGroup(g *Group) error

func (*SQLManager) CreateSchemas

func (s *SQLManager) CreateSchemas() (int, error)

func (*SQLManager) DeleteGroup

func (m *SQLManager) DeleteGroup(id string) error

func (*SQLManager) FindGroupNames

func (m *SQLManager) FindGroupNames(subject string) ([]string, error)

func (*SQLManager) GetGroup

func (m *SQLManager) GetGroup(id string) (*Group, error)

func (*SQLManager) RemoveGroupMembers

func (m *SQLManager) RemoveGroupMembers(group string, subjects []string) error

Jump to

Keyboard shortcuts

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