gateway

package
v0.2.0-fix-3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: GPL-3.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxExpiryAgeInSec int32  = 3600 * 24 * 7 // 7 days
	ExpiryDateFormat  string = time.RFC3339
)

Variables

View Source
var (
	// 4xx
	InvalidHeader            = &errorDescription{errorCode: "InvalidHeader", errorMessage: "The headers are invalid.", statusCode: http.StatusBadRequest}
	InvalidQuery             = &errorDescription{errorCode: "InvalidQuery", errorMessage: "The queries are invalid.", statusCode: http.StatusBadRequest}
	InvalidBucketName        = &errorDescription{errorCode: "InvalidBucketName", errorMessage: "The specified bucket is not valid.", statusCode: http.StatusBadRequest}
	InvalidKey               = &errorDescription{errorCode: "InvalidKey", errorMessage: "Object key is illegal", statusCode: http.StatusBadRequest}
	InvalidPayload           = &errorDescription{errorCode: "InvalidPayload", errorMessage: "Payload is empty", statusCode: http.StatusBadRequest}
	InvalidObjectState       = &errorDescription{errorCode: "InvalidObjectState", errorMessage: "Object state is invalid", statusCode: http.StatusForbidden}
	InvalidRange             = &errorDescription{errorCode: "InvalidRange", errorMessage: "Range is invalid", statusCode: http.StatusBadRequest}
	InvalidAddress           = &errorDescription{errorCode: "InvalidAddress", errorMessage: "Address is illegal", statusCode: http.StatusBadRequest}
	InvalidMaxKeys           = &errorDescription{errorCode: "InvalidMaxKeys", errorMessage: "MaxKeys is illegal", statusCode: http.StatusBadRequest}
	InvalidStartAfter        = &errorDescription{errorCode: "InvalidStartAfter", errorMessage: "StartAfter is illegal", statusCode: http.StatusBadRequest}
	InvalidContinuationToken = &errorDescription{errorCode: "InvalidContinuationToken", errorMessage: "ContinuationToken is illegal", statusCode: http.StatusBadRequest}
	InvalidPrefix            = &errorDescription{errorCode: "InvalidPrefix", errorMessage: "Prefix is illegal", statusCode: http.StatusBadRequest}
	SignatureNotMatch        = &errorDescription{errorCode: "SignatureDoesNotMatch", errorMessage: "SignatureDoesNotMatch", statusCode: http.StatusForbidden}
	AccessDenied             = &errorDescription{errorCode: "AccessDenied", errorMessage: "Access Denied", statusCode: http.StatusForbidden}
	OutOfQuota               = &errorDescription{errorCode: "AccessDenied", errorMessage: "Out of Quota", statusCode: http.StatusForbidden}
	NoSuchKey                = &errorDescription{errorCode: "NoSuchKey", errorMessage: "The specified key does not exist.", statusCode: http.StatusNotFound}
	NoSuchBucket             = &errorDescription{errorCode: "NoSuchBucket", errorMessage: "The specified bucket does not exist.", statusCode: http.StatusNotFound}
	NoRouter                 = &errorDescription{errorCode: "NoRouter", errorMessage: "The request can not route any handlers", statusCode: http.StatusNotFound}
	// 5xx
	InternalError          = &errorDescription{errorCode: "InternalError", errorMessage: "Internal Server Error", statusCode: http.StatusInternalServerError}
	NotImplementedError    = &errorDescription{errorCode: "NotImplementedError", errorMessage: "Not Implemented Error", statusCode: http.StatusNotImplemented}
	NotExistComponentError = &errorDescription{errorCode: "NotExistComponentError", errorMessage: "Not Existed Component Error", statusCode: http.StatusNotImplemented}
)

refer: https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html

View Source
var (
	// 4xx
	InvalidRegNonceHeader     = &errorDescription{errorCode: "InvalidRegNonceHeader", errorMessage: "The " + model.GnfdOffChainAuthAppRegNonceHeader + " header is incorrect.", statusCode: http.StatusBadRequest}
	SignedMsgNotMatchHeaders  = &errorDescription{errorCode: "SigMsgNotMatchHeaders", errorMessage: "The signed message in " + model.GnfdAuthorizationHeader + " does not match the content in headers.", statusCode: http.StatusBadRequest}
	SignedMsgNotMatchSPAddr   = &errorDescription{errorCode: "SignedMsgNotMatchSPAddr", errorMessage: "The signed message in " + model.GnfdAuthorizationHeader + " is not for the this SP.", statusCode: http.StatusBadRequest}
	SignedMsgNotMatchTemplate = &errorDescription{errorCode: "SignedMsgNotMatchTemplate", errorMessage: "The signed message in " + model.GnfdAuthorizationHeader + " does not match the template.", statusCode: http.StatusBadRequest}
	InvalidExpiryDateHeader   = &errorDescription{errorCode: "InvalidExpiryDateHeader",
		errorMessage: "The " + model.GnfdOffChainAuthAppRegExpiryDateHeader + " header is incorrect. " +
			"The expiry date is expected to be within " + strconv.Itoa(int(MaxExpiryAgeInSec)) + " seconds and formatted in YYYY-DD-MM HH:MM:SS 'GMT'Z, e.g. 2023-04-20 16:34:12 GMT+08:00 . ",
		statusCode: http.StatusBadRequest}
)

off-chain-auth errors

Functions

func RecoverAddr added in v0.1.2

func RecoverAddr(msg []byte, sig []byte) (sdk.AccAddress, ethsecp256k1.PubKey, error)

RecoverAddr recovers the sender address from msg and signature TODO: move it to greenfield-common

Types

type Gateway

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

Gateway is the primary entry point of SP

func NewGatewayService

func NewGatewayService(cfg *GatewayConfig) (*Gateway, error)

NewGatewayService return the gateway instance

func (*Gateway) Name

func (gateway *Gateway) Name() string

Name return the descriptions of gateway service

func (*Gateway) Start

func (gateway *Gateway) Start(ctx context.Context) error

Start gateway service

func (*Gateway) Stop

func (gateway *Gateway) Stop(ctx context.Context) error

Stop gateway service

type GatewayConfig

type GatewayConfig struct {
	SpOperatorAddress        string
	HTTPAddress              string
	Domain                   string
	ChainConfig              *gnfd.GreenfieldChainConfig
	UploaderServiceAddress   string
	DownloaderServiceAddress string
	SignerServiceAddress     string
	ChallengeServiceAddress  string
	ReceiverServiceAddress   string
	MetadataServiceAddress   string
	AuthServiceAddress       string
	APILimiterCfg            *localhttp.APILimiterConfig
	BandwidthLimitCfg        *localhttp.BandwidthLimiterConfig
}

GatewayConfig defines gateway service config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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