Documentation ¶
Index ¶
- Variables
- func FromStringAuthorizer(input string) (biscuit.ParsedAuthorizer, error)
- func FromStringAuthorizerWithParams(input string, parameters ParametersMap) (biscuit.ParsedAuthorizer, error)
- func FromStringBlock(input string) (biscuit.ParsedBlock, error)
- func FromStringBlockWithParams(input string, parameters ParametersMap) (biscuit.ParsedBlock, error)
- func FromStringCheck(input string) (biscuit.Check, error)
- func FromStringCheckWithParams(input string, parameters ParametersMap) (biscuit.Check, error)
- func FromStringFact(input string) (biscuit.Fact, error)
- func FromStringFactWithParams(input string, parameters ParametersMap) (biscuit.Fact, error)
- func FromStringPolicy(input string) (biscuit.Policy, error)
- func FromStringPolicyWithParams(input string, parameters ParametersMap) (biscuit.Policy, error)
- func FromStringRule(input string) (biscuit.Rule, error)
- func FromStringRuleWithParams(input string, parameters ParametersMap) (biscuit.Rule, error)
- type Allow
- type Authorizer
- type AuthorizerElement
- type Block
- type BlockElement
- type Bool
- type Check
- type CheckQuery
- type Comment
- type Deny
- type Expr1
- type Expr2
- type Expr3
- type Expr4
- type Expr5
- type Expr6
- type ExprTerm
- type Expression
- type HexString
- type MustParser
- type OpExpr1
- type OpExpr2
- type OpExpr3
- type OpExpr4
- type OpExpr5
- type OpExpr7
- type Operator
- type Parameter
- type ParametersMap
- type Parser
- type Policy
- type Predicate
- type Rule
- type RuleElement
- type Set
- type Term
- type Value
- type Variable
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrVariableInFact = errors.New("parser: a fact cannot contain any variables") ErrVariableInSet = errors.New("parser: a set cannot contain any variables") )
View Source
var BiscuitLexerRules = []lexer.SimpleRule{
{Name: "Keyword", Pattern: `check if|allow if|deny if`},
{Name: "Function", Pattern: `prefix|suffix|matches|length|contains`},
{Name: "Hex", Pattern: `hex:([0-9a-fA-F]{2})*`},
{Name: "Dot", Pattern: `\.`},
{Name: "Arrow", Pattern: `<-`},
{Name: "Or", Pattern: `\|\|`},
{Name: "And", Pattern: `&&`},
{Name: "Operator", Pattern: `==|>=|<=|>|<|\+|-|\*`},
{Name: "Comment", Pattern: `//[^\n]*`},
{Name: "String", Pattern: `\"[^\"]*\"`},
{Name: "Variable", Pattern: `\$[a-zA-Z0-9_:]+`},
{Name: "Parameter", Pattern: `\{[a-zA-Z0-9_:]+\}`},
{Name: "DateTime", Pattern: `\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(Z|([-+]\d\d:\d\d))?`},
{Name: "Int", Pattern: `[0-9]+`},
{Name: "Bool", Pattern: `true|false`},
{Name: "Ident", Pattern: `[a-z][a-zA-Z0-9_:]*`},
{Name: "Whitespace", Pattern: `[ \t]+`},
{Name: "EOL", Pattern: `[\n\r]+`},
{Name: "Punct", Pattern: `[-[!@%^&#$*()+_={}\|:;"'<,>.?/]|]`},
}
View Source
var DefaultParserOptions = []participle.Option{ participle.Lexer(lexer.MustSimple(BiscuitLexerRules)), participle.UseLookahead(1), participle.Elide("Whitespace", "EOL"), participle.Unquote("String"), }
Functions ¶
func FromStringAuthorizer ¶ added in v2.2.0
func FromStringAuthorizerWithParams ¶ added in v2.2.0
func FromStringAuthorizerWithParams(input string, parameters ParametersMap) (biscuit.ParsedAuthorizer, error)
func FromStringBlock ¶ added in v2.2.0
func FromStringBlockWithParams ¶ added in v2.2.0
func FromStringBlockWithParams(input string, parameters ParametersMap) (biscuit.ParsedBlock, error)
func FromStringCheck ¶
func FromStringCheckWithParams ¶ added in v2.2.0
func FromStringCheckWithParams(input string, parameters ParametersMap) (biscuit.Check, error)
func FromStringFact ¶
func FromStringFactWithParams ¶ added in v2.2.0
func FromStringFactWithParams(input string, parameters ParametersMap) (biscuit.Fact, error)
func FromStringPolicy ¶
func FromStringPolicyWithParams ¶ added in v2.2.0
func FromStringPolicyWithParams(input string, parameters ParametersMap) (biscuit.Policy, error)
func FromStringRule ¶
func FromStringRuleWithParams ¶ added in v2.2.0
func FromStringRuleWithParams(input string, parameters ParametersMap) (biscuit.Rule, error)
Types ¶
type Allow ¶
type Allow struct {
Queries []*CheckQuery `"allow if" @@ ( "or" @@ )*`
}
type Authorizer ¶ added in v2.2.0
type Authorizer struct { Comments []*Comment `@Comment*` Body []*AuthorizerElement `(@@ ";")*` }
func (*Authorizer) ToBiscuit ¶ added in v2.2.0
func (b *Authorizer) ToBiscuit(parameters ParametersMap) (*biscuit.ParsedAuthorizer, error)
type AuthorizerElement ¶ added in v2.2.0
type AuthorizerElement struct { Policy *Policy `@@` BlockElement *BlockElement `|@@` }
type Block ¶ added in v2.2.0
type Block struct { Comments []*Comment `@Comment*` Body []*BlockElement `(@@ ";")*` }
func (*Block) ToBiscuit ¶ added in v2.2.0
func (b *Block) ToBiscuit(parameters ParametersMap) (*biscuit.ParsedBlock, error)
type BlockElement ¶ added in v2.2.0
type BlockElement struct { Check *Check `@@` Predicate *Predicate `|@@` RuleBody []*RuleElement `("<-" @@ ("," @@)*)?` }
type Check ¶
type Check struct {
Queries []*CheckQuery `"check if" @@ ( "or" @@ )*`
}
func (*Check) ToBiscuit ¶
func (c *Check) ToBiscuit(parameters ParametersMap) (*biscuit.Check, error)
type CheckQuery ¶
type CheckQuery struct {
Body []*RuleElement `@@ ("," @@)*`
}
func (*CheckQuery) ToBiscuit ¶
func (r *CheckQuery) ToBiscuit(parameters ParametersMap) (*biscuit.Rule, error)
type Deny ¶
type Deny struct {
Queries []*CheckQuery `"deny if" @@ ( "or" @@ )*`
}
type Expr1 ¶
func (*Expr1) ToExpr ¶
func (e *Expr1) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expr2 ¶
func (*Expr2) ToExpr ¶
func (e *Expr2) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expr3 ¶
func (*Expr3) ToExpr ¶
func (e *Expr3) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expr4 ¶
func (*Expr4) ToExpr ¶
func (e *Expr4) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expr5 ¶
func (*Expr5) ToExpr ¶
func (e *Expr5) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expr6 ¶ added in v2.2.0
func (*Expr6) ToExpr ¶ added in v2.2.0
func (e *Expr6) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type ExprTerm ¶
type ExprTerm struct { Term *Term `@@` Expression *Expression `| "(" @@? ")"` }
func (*ExprTerm) ToExpr ¶
func (e *ExprTerm) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type Expression ¶
func (*Expression) ToExpr ¶
func (e *Expression) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type MustParser ¶
type MustParser interface { Fact(fact string, parameters ParametersMap) biscuit.Fact Rule(rule string, parameters ParametersMap) biscuit.Rule Check(check string, parameters ParametersMap) biscuit.Check Policy(policy string, parameters ParametersMap) biscuit.Policy Block(block string, parameters ParametersMap) biscuit.ParsedBlock Authorizer(authorizer string, parameters ParametersMap) biscuit.ParsedAuthorizer }
type OpExpr1 ¶
func (*OpExpr1) ToExpr ¶
func (e *OpExpr1) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type OpExpr2 ¶
func (*OpExpr2) ToExpr ¶
func (e *OpExpr2) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type OpExpr3 ¶
func (*OpExpr3) ToExpr ¶
func (e *OpExpr3) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type OpExpr4 ¶
func (*OpExpr4) ToExpr ¶
func (e *OpExpr4) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type OpExpr5 ¶
func (*OpExpr5) ToExpr ¶
func (e *OpExpr5) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type OpExpr7 ¶ added in v2.2.0
type OpExpr7 struct { Operator Operator `Dot @("matches" | "starts_with" | "ends_with" | "contains" | "union" | "intersection" | "length")` Expression *Expression `"(" @@? ")"` }
func (*OpExpr7) ToExpr ¶ added in v2.2.0
func (e *OpExpr7) ToExpr(expr *biscuit.Expression, parameters ParametersMap)
type ParametersMap ¶ added in v2.2.0
type ParametersMap map[string]biscuit.Term
type Parser ¶
type Parser interface { Fact(fact string, parameters ParametersMap) (biscuit.Fact, error) Rule(rule string, parameters ParametersMap) (biscuit.Rule, error) Check(check string, parameters ParametersMap) (biscuit.Check, error) Policy(policy string, parameters ParametersMap) (biscuit.Policy, error) Block(block string, parameters ParametersMap) (biscuit.ParsedBlock, error) Authorizer(authorizer string, parameters ParametersMap) (biscuit.ParsedAuthorizer, error) Must() MustParser }
type Policy ¶
func (*Policy) ToBiscuit ¶
func (p *Policy) ToBiscuit(parameters ParametersMap) (*biscuit.Policy, error)
type Predicate ¶
func (*Predicate) ToBiscuit ¶
func (p *Predicate) ToBiscuit(parameters ParametersMap) (*biscuit.Predicate, error)
type Rule ¶
type Rule struct { Comments []*Comment `@Comment*` Head *Predicate `@@` Body []*RuleElement `"<-" @@ ("," @@)*` }
func (*Rule) ToBiscuit ¶
func (r *Rule) ToBiscuit(parameters ParametersMap) (*biscuit.Rule, error)
type RuleElement ¶
type RuleElement struct { Predicate *Predicate `@@` Expression *Expression `|@@` }
type Term ¶
type Term struct { Parameter *Parameter `@Parameter` Variable *Variable `| @Variable` Bytes *HexString `| @@` String *string `| @String` Date *string `| @DateTime` Integer *int64 `| @Int` Bool *Bool `| @Bool` Set []*Term `| "[" @@ ("," @@)* "]"` }
func (*Term) ToBiscuit ¶
func (a *Term) ToBiscuit(parameters ParametersMap) (biscuit.Term, error)
Click to show internal directories.
Click to hide internal directories.