mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-01 11:26:29 +02:00
* ppl: pass contextual information through policy * maybe fix nginx * fix nginx * pr comments * go mod tidy
36 lines
818 B
Go
36 lines
818 B
Go
package criteria
|
|
|
|
import (
|
|
"github.com/open-policy-agent/opa/ast"
|
|
|
|
"github.com/pomerium/pomerium/pkg/policy/generator"
|
|
"github.com/pomerium/pomerium/pkg/policy/parser"
|
|
)
|
|
|
|
type rejectMatcher struct {
|
|
g *Generator
|
|
}
|
|
|
|
func (rejectMatcher) DataType() CriterionDataType {
|
|
return generator.CriterionDataTypeUnused
|
|
}
|
|
|
|
func (rejectMatcher) Name() string {
|
|
return "reject"
|
|
}
|
|
|
|
func (m rejectMatcher) GenerateRule(_ string, _ parser.Value) (*ast.Rule, []*ast.Rule, error) {
|
|
rule := m.g.NewRule("reject")
|
|
rule.Head.Value = NewCriterionTerm(false, ReasonReject)
|
|
rule.Body = ast.Body{ast.NewExpr(ast.BooleanTerm(true))}
|
|
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)
|
|
}
|