restapi

package
v0.0.0-...-3a21ec0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package restapi Credential Provider This is a Provider Credential Server that validates, signs, generates, revokes and updates credential to identify persons, institutions and objects.

The Provider Credential Server sign a credential using its own keys, it is configurable.

The Provider Credential needs to manage its own repository of credentials, default is smart contract that is deployed when server init.

The Credentials are verifiable against blockchain default, but you can configure and choose your proof and revocation list service.

Terms Of Service:

http://swagger.io/terms/

Schemes:
  http
  https
Host: localhost:8000
BasePath: /v1
Version: 0.0.1
License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html
Contact: <adriancc5.5@gmail.com>

Consumes:
- application/json
- application/xml

Produces:
- application/json
- application/xml

swagger:meta

Index

Constants

View Source
const (
	// DefaultServerPort is the default listening port for the fabric-ca server
	DefaultServerPort = 8000

	// DefaultServerAddr is the default listening address for the fabric-ca server
	DefaultServerAddr = "0.0.0.0"
)

Variables

View Source
var (
	// SwaggerJSON embedded version of the swagger document used at generation time
	SwaggerJSON json.RawMessage
	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
	FlatSwaggerJSON json.RawMessage
)

Functions

This section is empty.

Types

type BCCSP

type BCCSP struct {
	Hash     string `help:"version hash to use"`
	Security string `help:"Algorithm hashing to use, SHA1, SHA2, SHA3"`
	KeyStore string `help:"Path to file used to save keystore"`
}

BCCSP ...

type ProofConfig

type ProofConfig struct {
	Type         string `help:"proof type that can be smart contract, p-256 or secp256k1"`
	Verification string `help:"contract address or public key to verify digital signature"`
}

ProofConfig ...

type RepositoryConfig

type RepositoryConfig struct {
	Type    string `help:"repository type that saves credentials hash"`
	Address string `help:"smart contract address"`
}

RepositoryConfig ...

type Server

type Server struct {
	EnabledListeners []string         `long:"scheme" description:"the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec"`
	CleanupTimeout   time.Duration    `long:"cleanup-timeout" description:"grace period for which to wait before killing idle connections" default:"10s"`
	GracefulTimeout  time.Duration    `long:"graceful-timeout" description:"grace period for which to wait before shutting down the server" default:"15s"`
	MaxHeaderSize    flagext.ByteSize `` /* 231-byte string literal not displayed */

	SocketPath flags.Filename `long:"socket-path" description:"the unix socket to listen on" default:"/var/run/credential-provider.sock"`

	Host         string        `long:"host" description:"the IP to listen on" default:"localhost" env:"HOST"`
	Port         int           `long:"port" description:"the port to listen on for insecure connections, defaults to a random value" env:"PORT"`
	ListenLimit  int           `long:"listen-limit" description:"limit the number of outstanding requests"`
	KeepAlive    time.Duration `` /* 169-byte string literal not displayed */
	ReadTimeout  time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"`
	WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"`

	TLSHost           string         `long:"tlshost" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"`
	TLSPort           int            `long:"tlsport" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"`
	TLSCertificate    flags.Filename `long:"tlscertificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"`
	TLSCertificateKey flags.Filename `long:"tlskey" description:"the private key to use for secure conections" env:"TLS_PRIVATE_KEY"`
	TLSCACertificate  flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"`
	TLSListenLimit    int            `long:"tls-listen-limit" description:"limit the number of outstanding requests"`
	TLSKeepAlive      time.Duration  `` /* 160-byte string literal not displayed */
	TLSReadTimeout    time.Duration  `long:"tls-read-timeout" description:"maximum duration before timing out read of the request"`
	TLSWriteTimeout   time.Duration  `long:"tls-write-timeout" description:"maximum duration before timing out write of the response"`
	Secret            string         `long:"secret" description:"secret to enable keystore"`
	// contains filtered or unexported fields
}

Server for the credential provider API

func NewServer

func NewServer(api *operations.CredentialProviderAPI) *Server

NewServer creates a new api credential provider server but does not configure it

func (*Server) ConfigureAPI

func (s *Server) ConfigureAPI(config *ServerConfig)

ConfigureAPI configures the API and handlers.

func (*Server) ConfigureFlags

func (s *Server) ConfigureFlags()

ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse

func (*Server) Fatalf

func (s *Server) Fatalf(f string, args ...interface{})

Fatalf logs message either via defined user logger or via system one if no user logger is defined. Exits with non-zero status after printing

func (*Server) GetHandler

func (s *Server) GetHandler() http.Handler

GetHandler returns a handler useful for testing

func (*Server) HTTPListener

func (s *Server) HTTPListener() (net.Listener, error)

HTTPListener returns the http listener

func (*Server) Listen

func (s *Server) Listen() error

Listen creates the listeners for the server

func (*Server) Logf

func (s *Server) Logf(f string, args ...interface{})

Logf logs message either via defined user logger or via system one if no user logger is defined.

func (*Server) Serve

func (s *Server) Serve() (err error)

Serve the api

func (*Server) SetAPI

func (s *Server) SetAPI(api *operations.CredentialProviderAPI, config *ServerConfig)

SetAPI configures the server with the specified API. Needs to be called before Serve

func (*Server) SetHandler

func (s *Server) SetHandler(handler http.Handler)

SetHandler allows for setting a http handler on this server

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown server and clean up resources

func (*Server) TLSListener

func (s *Server) TLSListener() (net.Listener, error)

TLSListener returns the https listener

func (*Server) UnixListener

func (s *Server) UnixListener() (net.Listener, error)

UnixListener returns the domain socket listener

type ServerConfig

type ServerConfig struct {
	// Keystore Secret
	Secret string `def:"Password." opt:"x" help:"Keystore Secret"`
	// Listening port for the server
	Port int `def:"8001" opt:"p" help:"Listening port of credential-provider-server"`
	// Listening https port for the server
	TLSPort int `def:"8000" opt:"P" help:"Listening https port of credential-provider-server"`
	// Certificate to listen on TLS
	TLSCertificate string `def:"server.crt" opt:"s" help:"Certificate to listen on TLS"`
	// Certificate to listen on TLS
	TLSKey string `def:"server.key" opt:"t" help:"Certificate Private Key"`
	// Bind address for the server
	Host string `def:"0.0.0.0" help:"Listening address of credential-provider-server"`
	// Bind address TLS for the server
	TLSHost string `def:"0.0.0.0" help:"Listening address of TLS credential-provider-server"`
	// Enables debug logging
	Debug bool `def:"false" opt:"d" help:"Enable debug level logging" hide:"true"`
	// Sets the logging level on the server
	LogLevel string `help:"Set logging level (info, warning, debug, error, fatal, critical)"`
	// Node Blockchain to connect
	Node string `help:"Node URL Blockchain to connect through RPC o IPC"`
	// Issuer of Credentials
	Issuer string `help:"DID issuer that sign credentials"`
	// Private Key
	PrivateKey string `help:"KeyStore location to save private key"`
	// Ethereum Address
	Address string `help:"Ethereum address of private Key"`
	// Repository in blockchain
	Repository RepositoryConfig `help:"Set repository address in blockchain"`
	// Proof to verifiable credential
	Proof ProofConfig `help:"Set method verification of verifiable credential"`
	// Blockchain Crypto Service Provider
	Bccsp BCCSP `help:"Set hash algorithm and path keystore"`
}

ServerConfig is the credential provider server's config The tags are recognized by the RegisterFlags function in credentialprovider/util/flag.go and are as follows: "def" - the default value of the field; "opt" - the optional one character short name to use on the command line; "help" - the help message to display on the command line; "skip" - to skip the field.

Directories

Path Synopsis
did

Jump to

Keyboard shortcuts

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