validator

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package validator contains implementations of the ga4gh.Validator interface.

Index

Constants

This section is empty.

Variables

View Source
var RequestTTLInNanoFloat64 contextKey

RequestTTLInNanoFloat64 is the context key to use with golang.org/x/net/context's WithValue function to associate a "requested_ttl" value with a context.

Functions

func ValidatePolicy

func ValidatePolicy(policy *pb.Policy, defs map[string]*pb.VisaType, sources map[string]*pb.TrustedSource, args map[string]string) (string, error)

ValidatePolicy does basic validation for a policy and (optionally) the variable "args" that a policy instantiation uses.

Types

type And

type And []Validator

And is a Validator that returns false if any of the wrapped validators returns false. Evaluation short-circuits and does not necessarily evaluate all wrapped validators.

func (And) Validate

func (and And) Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)

Validate returns false if any of the wrapped validators return false. If any of the validators returns an error then an error is returned.

type ClaimValidator

type ClaimValidator struct {
	Name        string
	ConstantMap map[string]bool
	RegexValues []*regexp.Regexp
	IsNot       bool
	Sources     map[string]bool
	By          map[string]bool
}

ClaimValidator is a ga4gh.Validator that compares GA4GH claims.

func NewClaimValidator

func NewClaimValidator(name string, values []string, is string, sources map[string]bool, by map[string]bool) (*ClaimValidator, error)

NewClaimValidator creates a ClaimValidator instance.

func (*ClaimValidator) Validate

func (c *ClaimValidator) Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)

type Constant

type Constant struct {
	OK  bool
	Err error
}

Constant is a ga4gh.Validator that returns a set success and error value.

func (*Constant) Validate

func (c *Constant) Validate(context.Context, *ga4gh.Identity) (bool, error)

Validate always returns (c.OK, c.Err).

type MockValidator

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

MockValidator is a mock of Validator interface

func NewMockValidator

func NewMockValidator(ctrl *gomock.Controller) *MockValidator

NewMockValidator creates a new mock instance

func (*MockValidator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockValidator) Validate

func (m *MockValidator) Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)

Validate mocks base method

type MockValidatorMockRecorder

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

MockValidatorMockRecorder is the mock recorder for MockValidator

func (*MockValidatorMockRecorder) Validate

func (mr *MockValidatorMockRecorder) Validate(ctx, identity interface{}) *gomock.Call

Validate indicates an expected call of Validate

type Or

type Or []Validator

Or is a Validator that succeeds if any of the wrapped validators returns true. Evaluation short-circuits and does not necessarily evaluate all wrapped validators.

func (Or) Validate

func (or Or) Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)

Validate returns true iff one of the validators that this Or wraps returns true. If any of the invoked validators return an error then an error is returned.

type Policy

type Policy struct {
	Allow    Validator
	Disallow Validator
}

Policy is a ga4gh.Validator that succeeds if any of the wrapped validators returns true. Evaluation short-circuits and does not necessarily evaluate all wrapped validators.

func BuildPolicyValidator

func BuildPolicyValidator(ctx context.Context, policy *pb.Policy, defs map[string]*pb.VisaType, sources map[string]*pb.TrustedSource, args map[string]string) (*Policy, error)

BuildPolicyValidator creates a new policy validator.

func NewPolicy

func NewPolicy(allow Validator, disallow Validator) *Policy

func (Policy) Validate

func (r Policy) Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)

Validate returns true iff: 1. the allow clause is absent or it returns true; and 2. the disallow is absent or it returns false.

type Validator

type Validator interface {
	Validate(ctx context.Context, identity *ga4gh.Identity) (bool, error)
}

Validator is used to determine whether a given Identity is "valid" in a given context.

Jump to

Keyboard shortcuts

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