policy

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package policy offers management capabilities for access control policies. To read up on policies, go to:

- https://github.com/ory/ladon

- https://ory-am.gitbooks.io/hydra/content/policy.html

Contains source files:

- handler.go: A HTTP handler capable of managing policies.

- warden_http.go: A Go API using HTTP to validate managing policies.

- warden_test.go: Functional tests all of the above.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPManager

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

func (*HTTPManager) Create

func (m *HTTPManager) Create(policy ladon.Policy) error

Create persists the policy.

func (*HTTPManager) Delete

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

Delete removes a policy.

func (*HTTPManager) FindPoliciesForSubject

func (m *HTTPManager) FindPoliciesForSubject(subject string) (ladon.Policies, error)

Finds all policies associated with the subject.

func (*HTTPManager) Get

func (m *HTTPManager) Get(id string) (ladon.Policy, error)

Get retrieves a policy.

func (*HTTPManager) List added in v0.8.0

func (m *HTTPManager) List(limit, offset int64) (ladon.Policies, error)

Get retrieves a policy.

func (*HTTPManager) Update added in v0.7.0

func (m *HTTPManager) Update(policy ladon.Policy) error

Update the policy.

type Handler

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

func (*Handler) Create

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

swagger:route POST /policies policies createPolicy

Create an access control policy

Visit https://github.com/ory/ladon#usage for more information on policy usage.

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

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

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.policies

   Responses:
     201: policy
     401: genericError
     403: genericError
     500: genericError

func (*Handler) Delete

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

swagger:route DELETE /policies/{id} policies deletePolicy

Delete an access control policy

Visit https://github.com/ory/ladon#usage for more information on policy usage.

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

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

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.policies

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

func (*Handler) Get

swagger:route GET /policies/{id} policies getPolicy

Get an access control policy

Visit https://github.com/ory/ladon#usage for more information on policy usage.

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

```
{
  "resources": ["rn:hydra:policies:<id>"],
  "actions": ["get"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.policies

   Responses:
     200: policy
     401: genericError
     403: genericError
     500: genericError

func (*Handler) List added in v0.8.0

swagger:route GET /policies policies listPolicies

List access control policies

Visit https://github.com/ory/ladon#usage for more information on policy usage.

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

```
{
  "resources": ["rn:hydra:policies"],
  "actions": ["list"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.policies

   Responses:
     200: listPolicyResponse
     401: genericError
     403: genericError
     500: genericError

func (*Handler) SetRoutes

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

func (*Handler) Update added in v0.7.0

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

swagger:route PUT /policies/{id} policies updatePolicy

Update an access control policy

Visit https://github.com/ory/ladon#usage for more information on policy usage.

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

```
{
  "resources": ["rn:hydra:policies"],
  "actions": ["update"],
  "effect": "allow"
}
```

   Consumes:
   - application/json

   Produces:
   - application/json

   Schemes: http, https

   Security:
     oauth2: hydra.policies

   Responses:
     200: policy
     401: genericError
     403: genericError
     500: genericError

type Manager added in v0.7.0

type Manager interface {
	// Create persists the policy.
	Create(policy ladon.Policy) error

	// Get retrieves a policy.
	Get(id string) (ladon.Policy, error)

	// Delete removes a policy.
	Delete(id string) error

	// List policies.
	List(limit, offset int64) (ladon.Policies, error)

	// Update a policy.
	Update(policy ladon.Policy) error
}

Manager is responsible for managing and persisting policies.

Jump to

Keyboard shortcuts

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