adsrest

package
v0.0.0-...-1643d90 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2020 License: UPL-1.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvMultipleValues

func ConvMultipleValues(dataType string, values interface{}) (interface{}, error)

func ConvSingleValue

func ConvSingleValue(dataType string, value interface{}) (interface{}, error)

func ConvValue

func ConvValue(dataType string, value interface{}) (interface{}, error)

func ConvertAPIPolicy2PolicyResponse

func ConvertAPIPolicy2PolicyResponse(apiPolicy *adsapi.EvaluatedPolicy, policyResp *PolicyResponse)

func ConvertAPIRolePolicy2RolePolicyResponse

func ConvertAPIRolePolicy2RolePolicyResponse(apiRolePolicy *adsapi.EvaluatedRolePolicy, rolePolicyResp *RolePolicyResponse)

func ConvertJSONRequestToContext

func ConvertJSONRequestToContext(ctxContext *JsonContext) (*adsapi.RequestContext, error)

func DumpPrincipals

func DumpPrincipals(principals []*JsonPrincipal) []*adsapi.Principal

func DumpRequestAttributes

func DumpRequestAttributes(attrs []*JsonAttribute) (map[string]interface{}, error)

func DuplicateAttributeMap

func DuplicateAttributeMap(attrs map[string]interface{}) map[string]interface{}

func NewRouter

func NewRouter(evaluator eval.InternalEvaluator) (*mux.Router, error)

func ParseDateTime

func ParseDateTime(value string) (*time.Time, error)

func VerifyAttributeName

func VerifyAttributeName(attrName string) error

Types

type AuditEvaluationResult

type AuditEvaluationResult struct {
	Allowed string `json:"allowed"`
	Reason  string `json:"reason"`
}

type EvaluatedCondition

type EvaluatedCondition struct {
	ConditionExpression string `json:"conditionExpression,omitempty"`
	EvaluationResult    string `json:"evaluationResult,omitempty"`
}

type EvaluationDebugResponse

type EvaluationDebugResponse struct {
	Allowed        bool                   `json:"allowed"`
	Reason         string                 `json:"reason"`
	RequestContext JsonContext            `json:"requestContext,omitempty"`
	Attributes     map[string]interface{} `json:"attributes,omitempty"`
	GrantedRoles   []string               `json:"grantedRoles,omitempty"`
	RolePolicies   []RolePolicyResponse   `json:"rolePolicies,omitempty"`
	Policies       []PolicyResponse       `json:"policies,omitempty"`
}

Should we add Both of ReasonCode and ReasonMessage

type IsAllowedResponse

type IsAllowedResponse struct {
	Allowed      bool   `json:"allowed"`
	Reason       int32  `json:"reason"`
	ErrorMessage string `json:"errorMessage,omitempty"`
}

type JsonAttribute

type JsonAttribute struct {
	Name  string      `json:"name"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

type JsonContext

type JsonContext struct {
	Subject     *JsonSubject     `json:"subject"`
	ServiceName string           `json:"serviceName"`
	Resource    string           `json:"resource"`
	Action      string           `json:"action"`
	Attributes  []*JsonAttribute `json:"attributes"`
}

func DecodeJSONContext

func DecodeJSONContext(r *http.Request) (*JsonContext, error)

type JsonPrincipal

type JsonPrincipal struct {
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
	IDD  string `json:"idd,omitempty"`
}

type JsonSubject

type JsonSubject struct {
	Principals []*JsonPrincipal `json:"principals,omitempty"`
	TokenType  string           `json:"tokenType"`
	Token      string           `json:"token"`
}

type Permission

type Permission struct {
	Resource           string   `json:"resource,omitempty"`
	ResourceExpression string   `json:"resourceExpression,omitempty"`
	Actions            []string `json:"actions,omitempty"`
}

type PermissionResponse

type PermissionResponse struct {
	Resource string   `json:"resource"`
	Actions  []string `json:"actions"`
}

type PolicyResponse

type PolicyResponse struct {
	Status      string             `json:"status,omitempty"`
	ID          string             `json:"id,omitempty"`
	Name        string             `json:"name,omitempty"`
	Effect      string             `json:"effect,omitempty"`
	Permissions []Permission       `json:"permissions,omitempty"`
	Principals  [][]string         `json:"principals,omitempty"`
	Condition   EvaluatedCondition `json:"condition,omitempty"`
}

type RESTService

type RESTService struct {
	Evaluator eval.InternalEvaluator
}

func NewRESTService

func NewRESTService(conf *cfg.Config) (*RESTService, error)

func NewRESTServiceWithEvaluator

func NewRESTServiceWithEvaluator(evaluator eval.InternalEvaluator) (*RESTService, error)

func (*RESTService) Diagnose

func (e *RESTService) Diagnose(w http.ResponseWriter, r *http.Request)

func (*RESTService) Discover

func (e *RESTService) Discover(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetAllGrantedPermissions

func (e *RESTService) GetAllGrantedPermissions(w http.ResponseWriter, r *http.Request)

func (*RESTService) GetAllGrantedRoles

func (e *RESTService) GetAllGrantedRoles(w http.ResponseWriter, r *http.Request)

func (*RESTService) IsAllowed

func (e *RESTService) IsAllowed(w http.ResponseWriter, r *http.Request)

type RolePolicyResponse

type RolePolicyResponse struct {
	Status              string             `json:"status,omitempty"`
	ID                  string             `json:"id,omitempty"`
	Name                string             `json:"name,omitempty"`
	Effect              string             `json:"effect,omitempty"`
	Roles               []string           `json:"roles,omitempty"`
	Principals          []string           `json:"principals,omitempty"`
	Resources           []string           `json:"resources,omitempty"`
	ResourceExpressions []string           `json:"resourceExpressions,omitempty"`
	Condition           EvaluatedCondition `json:"condition,omitempty"`
}

Jump to

Keyboard shortcuts

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