Documentation ¶
Overview ¶
Package server provides a server object that represents the Notary backend
Index ¶
- Constants
- func AllowRequest(claims *jwtNotaryClaims, method, path string) (bool, error)
- func ChangeAccountPassword(env *HandlerConfig) http.HandlerFunc
- func CreateAccount(env *HandlerConfig) http.HandlerFunc
- func CreateCertificate(env *HandlerConfig) http.HandlerFunc
- func CreateCertificateRequest(env *HandlerConfig) http.HandlerFunc
- func DeleteAccount(env *HandlerConfig) http.HandlerFunc
- func DeleteCertificate(env *HandlerConfig) http.HandlerFunc
- func DeleteCertificateRequest(env *HandlerConfig) http.HandlerFunc
- func GetAccount(env *HandlerConfig) http.HandlerFunc
- func GetCertificateRequest(env *HandlerConfig) http.HandlerFunc
- func GetStatus(env *HandlerConfig) http.HandlerFunc
- func ListAccounts(env *HandlerConfig) http.HandlerFunc
- func ListCertificateRequests(env *HandlerConfig) http.HandlerFunc
- func Login(env *HandlerConfig) http.HandlerFunc
- func New(port int, cert []byte, key []byte, dbPath string, ...) (*http.Server, error)
- func NewHandler(config *HandlerConfig) http.Handler
- func RejectCertificate(env *HandlerConfig) http.HandlerFunc
- func SendPebbleNotification(key, request_id string) error
- type CertificateRequest
- type ChangeAccountParams
- type CreateAccountParams
- type CreateCertificateParams
- type CreateCertificateRequestParams
- type GetAccountResponse
- type HandlerConfig
- type LoginParams
- type LoginResponse
- type StatusResponse
- type SuccessResponse
Constants ¶
const ( UserPermission = 0 AdminPermission = 1 )
Variables ¶
This section is empty.
Functions ¶
func AllowRequest ¶
AllowRequest looks at the user data to determine the following things: The first question is "Is this user trying to access a path that's restricted?"
There are two types of restricted paths: admin only paths that only admins can access, and self authorized paths, which users are allowed to use only if they are taking an action on their own user ID. The second question is "If the path requires an ID, is the user attempting to access their own ID?"
For all endpoints and permission permutations, there are only 2 cases when users are allowed to use endpoints: If the URL path is not restricted to admins If the URL path is restricted to self authorized endpoints, and the user is taking action with their own ID This function validates that the user the with the given claims is allowed to use the endpoints by passing the above checks.
func ChangeAccountPassword ¶
func ChangeAccountPassword(env *HandlerConfig) http.HandlerFunc
func CreateAccount ¶
func CreateAccount(env *HandlerConfig) http.HandlerFunc
CreateAccount creates a new Account, and returns the id of the created row
func CreateCertificate ¶
func CreateCertificate(env *HandlerConfig) http.HandlerFunc
CreateCertificate handler receives an id as a path parameter, and attempts to add a given certificate to the corresponding certificate request
func CreateCertificateRequest ¶
func CreateCertificateRequest(env *HandlerConfig) http.HandlerFunc
CreateCertificateRequest creates a new Certificate Request, and returns the id of the created row
func DeleteAccount ¶
func DeleteAccount(env *HandlerConfig) http.HandlerFunc
DeleteAccount handler receives an id as a path parameter, deletes the corresponding User Account, and returns a http.StatusNoContent on success
func DeleteCertificate ¶
func DeleteCertificate(env *HandlerConfig) http.HandlerFunc
DeleteCertificate handler receives an id as a path parameter, and attempts to add a given certificate to the corresponding certificate request
func DeleteCertificateRequest ¶
func DeleteCertificateRequest(env *HandlerConfig) http.HandlerFunc
DeleteCertificateRequest handler receives an id as a path parameter, deletes the corresponding Certificate Request, and returns a http.StatusNoContent on success
func GetAccount ¶
func GetAccount(env *HandlerConfig) http.HandlerFunc
GetAccount receives an id as a path parameter, and returns the corresponding User Account
func GetCertificateRequest ¶
func GetCertificateRequest(env *HandlerConfig) http.HandlerFunc
GetCertificateRequest receives an id as a path parameter, and returns the corresponding Certificate Request
func GetStatus ¶
func GetStatus(env *HandlerConfig) http.HandlerFunc
the GET status endpoint returns a http.StatusOK alongside info about the server initialized means the first user has been created
func ListAccounts ¶
func ListAccounts(env *HandlerConfig) http.HandlerFunc
ListAccounts returns all accounts from the database
func ListCertificateRequests ¶
func ListCertificateRequests(env *HandlerConfig) http.HandlerFunc
ListCertificateRequests returns all of the Certificate Requests
func Login ¶
func Login(env *HandlerConfig) http.HandlerFunc
func New ¶
func New(port int, cert []byte, key []byte, dbPath string, pebbleNotificationsEnabled bool) (*http.Server, error)
New creates an environment and an http server with handlers that Go can start listening to
func NewHandler ¶
func NewHandler(config *HandlerConfig) http.Handler
NewHandler takes in a config struct, passes it along to any handlers that will need access to it, and takes an http.Handler that will be used to handle metrics. then builds and returns it for a server to consume
func RejectCertificate ¶
func RejectCertificate(env *HandlerConfig) http.HandlerFunc
func SendPebbleNotification ¶
Types ¶
type CertificateRequest ¶
type ChangeAccountParams ¶
type ChangeAccountParams struct {
Password string `json:"password"`
}
type CreateAccountParams ¶
type CreateCertificateParams ¶
type CreateCertificateParams struct {
CertificateChain string `json:"certificate"`
}
type CreateCertificateRequestParams ¶
type CreateCertificateRequestParams struct {
CSR string `json:"csr"`
}
type GetAccountResponse ¶
type HandlerConfig ¶
type LoginParams ¶
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
}
type StatusResponse ¶
type SuccessResponse ¶
type SuccessResponse struct {
Message string `json:"message"`
}