Documentation ¶
Index ¶
- Constants
- Variables
- func Authorizer(ks *keystar.KeyStar) func(next http.Handler) http.Handler
- func ContentTypeValidator(fn func(contentType string) bool) func(next http.Handler) http.Handler
- func JSONValidator(contentType string) bool
- func NewAuthorizerHandler(ks *keystar.KeyStar) *authorizer
- type AuthorizationHandler
- type Config
- type GeneratorController
- type JSONStatusCode
- type KeyBuffer
- type KeyController
- func (k *KeyController) Delete(ctx capstan.Context) error
- func (k *KeyController) Get(ctx capstan.Context) error
- func (k *KeyController) Init(dm *mappers.DependencyMapper)
- func (k *KeyController) Patch(ctx capstan.Context) error
- func (k *KeyController) Post(ctx capstan.Context) error
- func (k *KeyController) Put(ctx capstan.Context) error
- type KeyRingController
- func (k *KeyRingController) Get(ctx capstan.Context) error
- func (k *KeyRingController) Init(dm *mappers.DependencyMapper)
- func (k *KeyRingController) Patch(ctx capstan.Context) error
- func (k *KeyRingController) Post(ctx capstan.Context) error
- func (k *KeyRingController) Put(ctx capstan.Context) error
- type KeyRingCreateController
- type NamespaceController
- type RotateController
- type Server
- type ServerConfig
- type TemplateController
Constants ¶
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 ¶
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 ¶
Authorizer creates a new authorization handler. This utilizes the authorizer struct for managing internal state, mostly for key signing.
func ContentTypeValidator ¶
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 ¶
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 ¶
Types ¶
type AuthorizationHandler ¶
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 JSONStatusCode ¶
type KeyBuffer ¶
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.
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 (k *KeyRingController) Init(dm *mappers.DependencyMapper)
type KeyRingCreateController ¶
type KeyRingCreateController struct { capstan.BaseController KS *keystar.KeyStar `inject:"-"` Logger *logging.Log `inject:"-"` // contains filtered or unexported fields }
func (*KeyRingCreateController) Delete ¶
func (k *KeyRingCreateController) Delete(ctx capstan.Context) error
Delete the entire key ring and all its contents.
func (*KeyRingCreateController) Init ¶
func (k *KeyRingCreateController) Init(dm *mappers.DependencyMapper)
type NamespaceController ¶
type NamespaceController struct { capstan.BaseController KS *keystar.KeyStar `dependency:"inject"` Logger *logging.Log `dependency:"inject"` }
type RotateController ¶
type RotateController struct { capstan.BaseController KS *keystar.KeyStar `inject:"-"` Logger *logging.Log `inject:"-"` // contains filtered or unexported fields }
func (*RotateController) Init ¶
func (r *RotateController) Init(dm *mappers.DependencyMapper)
type Server ¶
func (*Server) Configure ¶
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) SetKeyStar ¶
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 (t *TemplateController) Init(dm *mappers.DependencyMapper)