mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
Pomerium Policy Language (#2202)
* policy: add parser and generator for Pomerium Policy Language * add criteria * add additional criteria
This commit is contained in:
parent
9fe941ccee
commit
e138054cb9
33 changed files with 2758 additions and 0 deletions
35
pkg/policy/criteria/reject.go
Normal file
35
pkg/policy/criteria/reject.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package criteria
|
||||
|
||||
import (
|
||||
"github.com/open-policy-agent/opa/ast"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/policy/parser"
|
||||
)
|
||||
|
||||
var rejectBody = ast.Body{
|
||||
ast.MustParseExpr(`v := false`),
|
||||
}
|
||||
|
||||
type rejectMatcher struct {
|
||||
g *Generator
|
||||
}
|
||||
|
||||
func (rejectMatcher) Names() []string {
|
||||
return []string{"reject"}
|
||||
}
|
||||
|
||||
func (m rejectMatcher) GenerateRule(_ string, _ parser.Value) (*ast.Rule, []*ast.Rule, error) {
|
||||
rule := m.g.NewRule("reject")
|
||||
rule.Head.Value = ast.VarTerm("v")
|
||||
rule.Body = rejectBody
|
||||
return rule, nil, nil
|
||||
}
|
||||
|
||||
// Reject returns a Criterion which always returns false.
|
||||
func Reject(generator *Generator) Criterion {
|
||||
return rejectMatcher{g: generator}
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(Reject)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue