auth

package
v0.0.0-...-e9c30ff Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPCountryFromContext

func IPCountryFromContext(ctx context.Context) string

func RemoteAddressFromContext

func RemoteAddressFromContext(ctx context.Context) string

func UserClaimsFromContext

func UserClaimsFromContext(ctx context.Context) auth.User

Types

type Interceptor

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

Interceptor intercepts gRPC requests to ensure user authentication and authorization

func New

func New(jwtManager *auth.JWTManager, authorizer UserAuthorizer) *Interceptor

New returns a new Interceptor

func (*Interceptor) SetMinimumPermissionLevelForMethod

func (interceptor *Interceptor) SetMinimumPermissionLevelForMethod(method string, level auth.PermissionLevel)

SetMinimumPermissionLevelForMethod sets the minimum permission level required to use the given method

func (*Interceptor) Stream

func (interceptor *Interceptor) Stream() grpc.StreamServerInterceptor

Stream intercepts stream RPC requests

func (*Interceptor) Unary

func (interceptor *Interceptor) Unary() grpc.UnaryServerInterceptor

Unary intercepts unary RPC requests

type UserAuthorizer

type UserAuthorizer interface {
	IsRemoteAddressAllowed(remoteAddr string) bool
	IsRewardAddressAllowed(rewardAddr string) bool
}

UserAuthorizer allows for checking if users are authorized to use the service

Jump to

Keyboard shortcuts

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