legal

package
v4.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

This package enables filtering using Legal service in go-restful apps.

Usage

Importing
import "github.com/AccelByte/go-restful-plugins/pkg/auth/legal"
Create filter

This filter depends on Legal client passed through the constructor.

filter := legal.NewFilter(legalClient)
Constructing filter

The default Eligibility() filter validates the accepted policy versions in JWT claims against the latest crucial mandatory policies.

ws := new(restful.WebService)
ws.Filter(filter.Eligibility())
Reading JWT Claims

Eligibility() filter will get JWT claims to restful.Request.attribute from the Auth() filter.

Note

Retrieved claims can be nil if the request not filtered using Auth() first.

Filter all endpoints
ws := new(restful.WebService)
ws.Filter(filter.Eligibility())
Filter specific endpoint
ws := new(restful.WebService)
ws.Route(ws.GET("/user/{id}").
    Filter(filter.Eligibility()).
    To(func(request *restful.Request, response *restful.Response) {
}))

Documentation

Index

Constants

View Source
const (
	// Global Error Codes
	UnauthorizedAccess = 20001
	UserNotEligible    = 20020
)

Variables

View Source
var ErrorCodeMapping = map[int]string{

	UnauthorizedAccess: "unauthorized access",
	UserNotEligible:    "user is not eligible",
}

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    int    `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
}

ErrorResponse is the generic structure for communicating errors from a REST endpoint.

type Filter

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

Filter handles eligibility using filter

func NewFilter

func NewFilter(client legal.LegalClient) *Filter

NewFilter creates new Filter instance

func (*Filter) Eligibility

func (filter *Filter) Eligibility() restful.FilterFunction

Jump to

Keyboard shortcuts

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