auth

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package auth is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClaimHandler

func AddClaimHandler(next http.Handler, logger *zerolog.Logger, vehicleAddr, mfrAddr string) http.Handler

AddClaimHandler is a middleware that fills in GraphQL-friendly privilege information on the *TelemetryClaim object in the context.

func ErrorHandler

func ErrorHandler(logger *zerolog.Logger) func(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler is a custom error handler for the jwt middleware. It logs the error and then calls the default error handler.

func NewJWTMiddleware

func NewJWTMiddleware(issuer, jwksURI, vehAddr, mfrAddr string, logger *zerolog.Logger) (*jwtmiddleware.JWTMiddleware, error)

NewJWTMiddleware creates a new JWT middleware with the given issuer and contract address. This middleware will validate the token and add the claim to the context.

func NewManufacturerTokenCheck added in v0.0.23

func NewManufacturerTokenCheck(contractAddr string, identitySvc IdentityService) func(context.Context, any, graphql.Resolver) (any, error)

func NewVehicleTokenCheck added in v0.0.23

func NewVehicleTokenCheck(contractAddr string) func(context.Context, any, graphql.Resolver) (any, error)

func PrivilegeCheck added in v0.0.21

func PrivilegeCheck(ctx context.Context, _ any, next graphql.Resolver, privs []model.Privilege) (any, error)

PrivilegeCheck checks if the claim set in the context includes the required privileges.

Types

type IdentityService added in v0.0.23

type IdentityService interface {
	GetAftermarketDevice(ctx context.Context, address *common.Address, tokenID *int, serial *string) (*identity.DeviceInfos, error)
}

type MockIdentityService added in v0.0.23

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

MockIdentityService is a mock of IdentityService interface.

func NewMockIdentityService added in v0.0.23

func NewMockIdentityService(ctrl *gomock.Controller) *MockIdentityService

NewMockIdentityService creates a new mock instance.

func (*MockIdentityService) EXPECT added in v0.0.23

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

func (*MockIdentityService) GetAftermarketDevice added in v0.0.23

func (m *MockIdentityService) GetAftermarketDevice(ctx context.Context, address *common.Address, tokenID *int, serial *string) (*identity.DeviceInfos, error)

GetAftermarketDevice mocks base method.

type MockIdentityServiceMockRecorder added in v0.0.23

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

MockIdentityServiceMockRecorder is the mock recorder for MockIdentityService.

func (*MockIdentityServiceMockRecorder) GetAftermarketDevice added in v0.0.23

func (mr *MockIdentityServiceMockRecorder) GetAftermarketDevice(ctx, address, tokenID, serial any) *gomock.Call

GetAftermarketDevice indicates an expected call of GetAftermarketDevice.

type TelemetryClaim

type TelemetryClaim struct {
	privilegetoken.CustomClaims
	// contains filtered or unexported fields
}

TelemetryClaim is a custom claim for the telemetry API.

func (*TelemetryClaim) SetPrivileges

func (t *TelemetryClaim) SetPrivileges(contractPrivMaps map[common.Address]map[privileges.Privilege]model.Privilege)

SetPrivileges populates the set of GraphQL privileges on the claim object. To do this, it combines the address and privilege ids on the token together with the given map.

func (*TelemetryClaim) Validate

func (t *TelemetryClaim) Validate(context.Context) error

Validate function is required to implement the validator.CustomClaims interface.

type TelemetryClaimContextKey

type TelemetryClaimContextKey struct{}

TelemetryClaimContextKey is a custom key for the context to store the custom claims.

type TokenValidator added in v0.0.23

type TokenValidator struct {
	IdentitySvc IdentityService
}

type UnauthorizedError added in v0.0.21

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

func (UnauthorizedError) Error added in v0.0.21

func (e UnauthorizedError) Error() string

func (UnauthorizedError) Unwrap added in v0.0.21

func (e UnauthorizedError) Unwrap() error

Jump to

Keyboard shortcuts

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