server

package
v0.0.0-...-7eb8b13 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: NCSA Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const ServerVersion = "0.1.0"

ServerVersion declares the version used by the server API defined in this package and its associated data types. Semver is followed somewhat closely by this identifier: Patch levels indicate fixes to the server API where published behavior and code behavior may not align, minor version bumps indicate new features or changes to the server API that may induce minor code breakage, and major version bumps indicate significant server API changes that are guaranteed to break downstream code.

Variables

View Source
var KeyStarCertificate = x509.Certificate{
	Version:      1,
	SerialNumber: big.NewInt(1),
	Subject: pkix.Name{
		Country:            []string{"US"},
		Organization:       []string{"keystar"},
		OrganizationalUnit: []string{},
		Locality:           []string{"NA"},
		Province:           []string{},
		StreetAddress:      []string{"Invalid"},
		PostalCode:         []string{"Invalid"},
		SerialNumber:       "1",
		CommonName:         "",
	},
	NotBefore:             time.Now().Add(time.Hour * -2),
	NotAfter:              time.Now().Add(time.Hour * 24 * 30 * 3),
	KeyUsage:              x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
	ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
	IsCA:                  true,
	BasicConstraintsValid: true,
}

Functions

func Authorizer

func Authorizer(ks *keystar.KeyStar) func(next http.Handler) http.Handler

Authorizer creates a new authorization handler. This utilizes the authorizer struct for managing internal state, mostly for key signing.

func ContentTypeValidator

func ContentTypeValidator(fn func(contentType string) bool) func(next http.Handler) http.Handler

ContentTypeValidator either abandons the existing request of continues, depending on whether the request's Content-Type matches that defined by the function `fn`, which validates the types externally. See JSONValidator, below, for an illustration of how this may work.

func JSONValidator

func JSONValidator(contentType string) bool

JSONValidator is a validation function for ContentTypeValidator that verifies that the current request contains an appropriate content-Type header for the expected request payload.

func NewAuthorizerHandler

func NewAuthorizerHandler(ks *keystar.KeyStar) *authorizer

Types

type AuthorizationHandler

type AuthorizationHandler struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
}

func (*AuthorizationHandler) Get

func (*AuthorizationHandler) Post

type Config

type Config struct {
	// Host address to which KeyStar will listen. "::" or "0.0.0.0 "to listen on
	// all interfaces, depending on protocol support. When in doubt, use "::".
	Host string

	// Port address on which to listen. Default: 9911.
	Port int

	// URI of the key storage. This should include the protocol type, hostspec, or
	// path, depending on protocol.
	URI string

	// Key. Unused.
	Key string

	// TLS enable. Default: false.
	TLS bool

	// CertificatePath for TLS support. By default, this will be "keystar.pem".
	CertificatePath string

	// KeyPath for TLS support. By default, this will be "keystar.key".
	KeyPath string

	// GenerateKeyPair for TLS support. If true, this will automatically generate
	// a self-signed certificate that may then be used by clients supporting both
	// TLS and the ability to specify additional keys.
	GenerateKeyPair bool
}

type GeneratorController

type GeneratorController struct {
	Logger *logging.Log `inject:"-"`
}

type JSONStatusCode

type JSONStatusCode struct {
	Text string `json:"error"`
	Help string `json:"help,omitempty"`
}

type KeyBuffer

type KeyBuffer struct {
	Key  *bytes.Buffer
	Cert *bytes.Buffer
}

func GenerateSelfSignedCertificate

func GenerateSelfSignedCertificate(template *x509.Certificate) (KeyBuffer, error)

Generates a self-signed certificate using `path` as its root directory for export.

type KeyController

type KeyController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
	// contains filtered or unexported fields
}

func (*KeyController) Delete

func (k *KeyController) Delete(ctx capstan.Context) error

Delete a specific key or composite key.

func (*KeyController) Get

func (k *KeyController) Get(ctx capstan.Context) error

Get retrieves a specific key plus its associated key ring metadata.

func (*KeyController) Init

func (k *KeyController) Init(dm *mappers.DependencyMapper)

Init local variables.

func (*KeyController) Patch

func (k *KeyController) Patch(ctx capstan.Context) error

func (*KeyController) Post

func (k *KeyController) Post(ctx capstan.Context) error

Post attempts to create the named key, failing if it exists.

func (*KeyController) Put

func (k *KeyController) Put(ctx capstan.Context) error

Put creates or retrieves the specified key.

type KeyRingController

type KeyRingController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
	// contains filtered or unexported fields
}

KeyRingController manages and views key ring contents. To view specific key contents, see the KeyController (above). Note that the configured POST request method strictly attaches keys to this key ring, whereas PUT manipulates this key ring directly.

URIs:

  • Implicit global namespace: /keyring/<keyring:string>/?
  • Specific namespace: /keyring/<namespace:string>/<keyring:string>/?

Symbolic names (URL for):

  • global.keyring
  • namespace.keyring

Methods:

Get: Retrieves a key ring and its keys. Delete: Deletes a key ring and its contents. Post: Creates a new key key or fails if it exists. Put: Creates or retrieves a key ring.

func (*KeyRingController) Get

func (k *KeyRingController) Get(ctx capstan.Context) error

Get retrieves the key ring contents for a given namespace. The entirey key ring is retrieved, including all keys. For specific keys, see KeyController.

func (*KeyRingController) Init

func (*KeyRingController) Patch

func (k *KeyRingController) Patch(ctx capstan.Context) error

func (*KeyRingController) Post

func (k *KeyRingController) Post(ctx capstan.Context) error

Post a new key to the key ring. This will create the key if it doesn't exist or return an error if it does.

func (*KeyRingController) Put

func (k *KeyRingController) Put(ctx capstan.Context) error

Put attempts to create or retrieve the specified key ring and its contents.

type KeyRingCreateController

type KeyRingCreateController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
	// contains filtered or unexported fields
}

func (*KeyRingCreateController) Delete

Delete the entire key ring and all its contents.

func (*KeyRingCreateController) Init

func (*KeyRingCreateController) Post

type NamespaceController

type NamespaceController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `dependency:"inject"`
	Logger *logging.Log     `dependency:"inject"`
}

func (*NamespaceController) Delete

func (n *NamespaceController) Delete(ctx capstan.Context) error

func (*NamespaceController) Post

type RotateController

type RotateController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
	// contains filtered or unexported fields
}

func (*RotateController) Init

func (*RotateController) Post

func (r *RotateController) Post(ctx capstan.Context) error

type Server

type Server struct {
	Logger *logging.Log
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *Config) *Server

func (*Server) Configure

func (s *Server) Configure() error

Configure the server, optionally returning an error if a failure occurs during configuration.

This will return the following errors:

- ErrDecoding if a composite key was provided but could not be processed. - ErrCreatingStorage if a configuration error occurred during storage initialization or the storage backend failed.

func (*Server) Handler

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

func (*Server) Serve

func (s *Server) Serve()

Serve listens on and starts the HTTP server.

func (*Server) SetKeyStar

func (s *Server) SetKeyStar(ks *keystar.KeyStar)

type ServerConfig

type ServerConfig struct {
	Server *Config `yaml:"server"`
}

type TemplateController

type TemplateController struct {
	capstan.BaseController
	KS     *keystar.KeyStar `inject:"-"`
	Logger *logging.Log     `inject:"-"`
	// contains filtered or unexported fields
}

func (*TemplateController) Init

func (*TemplateController) Post

func (t *TemplateController) Post(ctx capstan.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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