rule

package
v0.11.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const AnonymousMode = "anonymous"
View Source
const AuthenticatedMode = "authenticated"
View Source
const BypassMode = "bypass"
View Source
const PolicyMode = "policy"

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedMatcher

type CachedMatcher struct {
	Rules   []Rule
	Manager Manager
}

func (*CachedMatcher) MatchRule

func (m *CachedMatcher) MatchRule(method string, u *url.URL) (*Rule, error)

func (*CachedMatcher) Refresh

func (m *CachedMatcher) Refresh() error

type Handler

type Handler struct {
	H herodot.Writer
	M Manager
}

func (*Handler) Create

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

swagger:route POST /rules rule createRule

Create a rule

This method allows creation of rules. If a rule id exists, you will receive an error.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Responses:
  201: rule
  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 /rules/{id} rule deleteRule

Delete a rule

Use this endpoint to delete a rule.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

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

func (*Handler) Get

swagger:route GET /rules/{id} rule getRule

Retrieve a rule

Use this method to retrieve a rule from the storage. If it does not exist you will receive a 404 error.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Responses:
  200: rule
  401: genericError
  403: genericError
  404: genericError
  500: genericError

func (*Handler) List

swagger:route GET /rules rule listRules

List all rules

This method returns an array of all rules that are stored in the backend. This is useful if you want to get a full view of what rules you have currently in place.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Responses:
  200: rules
  401: genericError
  403: genericError
  500: genericError

func (*Handler) SetRoutes

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

func (*Handler) Update

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

swagger:route PUT /rules/{id} rule updateRule

Update a rule

Use this method to update a rule. Keep in mind that you need to send the full rule payload as this endpoint does not support patching.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Responses:
  200: rule
  401: genericError
  403: genericError
  404: genericError
  500: genericError

type Manager

type Manager interface {
	ListRules() ([]Rule, error)
	CreateRule(*Rule) error
	GetRule(id string) (*Rule, error)
	DeleteRule(id string) error
	UpdateRule(*Rule) error
}

type Matcher

type Matcher interface {
	MatchRule(method string, u *url.URL) (*Rule, error)
}

type MemoryManager

type MemoryManager struct {
	Rules map[string]Rule
}

func NewMemoryManager

func NewMemoryManager() *MemoryManager

func (*MemoryManager) CreateRule

func (m *MemoryManager) CreateRule(rule *Rule) error

func (*MemoryManager) DeleteRule

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

func (*MemoryManager) GetRule

func (m *MemoryManager) GetRule(id string) (*Rule, error)

func (*MemoryManager) ListRules

func (m *MemoryManager) ListRules() ([]Rule, error)

func (*MemoryManager) UpdateRule

func (m *MemoryManager) UpdateRule(rule *Rule) error

type Rule

type Rule struct {
	// ID is the unique id of the rule. It can be at most 190 characters long, but the layout of the ID is up to you.
	// You will need this ID later on to update or delete the rule.
	ID string

	// MatchesMethods as an array of HTTP methods (e.g. GET, POST, PUT, DELETE, ...). When ORY Oathkeeper searches for rules
	// to decide what to do with an incoming request to the proxy server, it compares the HTTP method of the incoming
	// request with the HTTP methods of each rules. If a match is found, the rule is considered a partial match.
	MatchesMethods []string

	// MatchesURLCompiled is a regular expression of paths this rule matches.
	MatchesURLCompiled *regexp.Regexp

	// MatchesURL is a regular expression of paths this rule matches.
	MatchesURL string

	// RequiredScopes is a list of scopes that are required by this rule.
	RequiredScopes []string

	// RequiredScopes is the action this rule requires.
	RequiredAction string

	// RequiredScopes is the resource this rule requires.
	RequiredResource string

	// Mode is the mode this rule enforces.
	Mode string

	// Description describes the rule.
	Description string
}

Rule is a single rule that will get checked on every HTTP request.

func (*Rule) IsMatching

func (r *Rule) IsMatching(method string, u *url.URL) error

type SQLManager

type SQLManager struct {
	// contains filtered or unexported fields
}

func NewSQLManager

func NewSQLManager(db *sqlx.DB) *SQLManager

func (*SQLManager) CreateRule

func (s *SQLManager) CreateRule(rule *Rule) error

func (*SQLManager) CreateSchemas

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

func (*SQLManager) DeleteRule

func (s *SQLManager) DeleteRule(id string) error

func (*SQLManager) GetRule

func (s *SQLManager) GetRule(id string) (*Rule, error)

func (*SQLManager) ListRules

func (s *SQLManager) ListRules() ([]Rule, error)

func (*SQLManager) UpdateRule

func (s *SQLManager) UpdateRule(rule *Rule) error

Jump to

Keyboard shortcuts

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