server

package
v0.0.0-...-b450725 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package server provides a server object that represents the Notary backend

Index

Constants

View Source
const (
	USER_ACCOUNT  = 0
	ADMIN_ACCOUNT = 1
)

Variables

This section is empty.

Functions

func AllowRequest

func AllowRequest(claims *jwtNotaryClaims, method, path string) (bool, error)

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 ChangeUserAccountPassword

func ChangeUserAccountPassword(env *Environment) http.HandlerFunc

func DeleteCertificate

func DeleteCertificate(env *Environment) 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 *Environment) http.HandlerFunc

DeleteCertificateRequest handler receives an id as a path parameter, deletes the corresponding Certificate Request, and returns a http.StatusNoContent on success

func DeleteUserAccount

func DeleteUserAccount(env *Environment) http.HandlerFunc

DeleteUserAccount handler receives an id as a path parameter, deletes the corresponding User Account, and returns a http.StatusNoContent on success

func GetCertificateRequest

func GetCertificateRequest(env *Environment) http.HandlerFunc

GetCertificateRequests receives an id as a path parameter, and returns the corresponding Certificate Request

func GetCertificateRequests

func GetCertificateRequests(env *Environment) http.HandlerFunc

GetCertificateRequests returns all of the Certificate Requests

func GetUserAccount

func GetUserAccount(env *Environment) http.HandlerFunc

GetUserAccount receives an id as a path parameter, and returns the corresponding User Account

func GetUserAccounts

func GetUserAccounts(env *Environment) http.HandlerFunc

GetUserAccounts returns all users from the database

func HealthCheck

func HealthCheck(env *Environment) http.HandlerFunc

the health check endpoint returns a http.StatusOK alongside info about the server initialized means the first user has been created

func Login

func Login(env *Environment) http.HandlerFunc

func NewNotaryRouter

func NewNotaryRouter(env *Environment) http.Handler

NewNotaryRouter takes in an environment 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 NewServer

func NewServer(port int, cert []byte, key []byte, dbPath string, pebbleNotificationsEnabled bool) (*http.Server, error)

NewServer creates an environment and an http server with handlers that Go can start listening to

func PostCertificate

func PostCertificate(env *Environment) http.HandlerFunc

PostCertificate handler receives an id as a path parameter, and attempts to add a given certificate to the corresponding certificate request

func PostCertificateRequest

func PostCertificateRequest(env *Environment) http.HandlerFunc

PostCertificateRequest creates a new Certificate Request, and returns the id of the created row

func PostUserAccount

func PostUserAccount(env *Environment) http.HandlerFunc

PostUserAccount creates a new User Account, and returns the id of the created row

func RejectCertificate

func RejectCertificate(env *Environment) http.HandlerFunc

func SendPebbleNotification

func SendPebbleNotification(key, request_id string) error

Types

type Environment

type Environment struct {
	DB                      *db.Database
	SendPebbleNotifications bool
	JWTSecret               []byte
}

Jump to

Keyboard shortcuts

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