service

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClaims

type AuthClaims struct {
	jwt.StandardClaims
}

AuthClaims defines standard claims for authentication.

type Config

type Config struct {
	Listener    net.Listener
	PostgresURI string
}

Config is the service config.

type Deps

type Deps struct {
	NearAPI chainapi.ChainAPI
	EthAPI  chainapi.ChainAPI
	PolyAPI chainapi.ChainAPI
}

Deps comprises the service dependencies.

type Service

type Service struct {
	pb.UnimplementedAuthAPIServiceServer
	Config
	Deps
	// contains filtered or unexported fields
}

Service is a gRPC service for authorization.

func New

func New(config Config, deps Deps) (*Service, error)

New returns a new service.

func (*Service) Auth

func (s *Service) Auth(ctx context.Context, req *pb.AuthRequest) (*pb.AuthResponse, error)

Auth authenticates a user storage request. It detects raw bearer tokens or JTWs associated with the NEAR blockchain. The latter is an URL encoded base64 JWT with an Ed25519 signature. 1. Validates the JWT 2. Validates that the key DID in the JWT ("sub" in the payload) was created with the public key ("x" in the header) 3. Validates that the user has locked funds on-chain using a service provided by neard. It returns the key DID.

func (*Service) Close

func (s *Service) Close() error

Close the service.

type ValidatedToken

type ValidatedToken struct {
	Sub       string
	Iss       string
	Aud       string
	PublicID  string
	Origin    string
	Suborigin string
}

ValidatedToken represents token data that has been validated.

Jump to

Keyboard shortcuts

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