Documentation ¶
Index ¶
- Constants
- type AccessToken
- type ErrorResponse
- type Server
- func (s *Server) AccessTokenMiddleware(required bool) func(c *gin.Context)
- func (s *Server) AllowIpMiddleware() (gin.HandlerFunc, error)
- func (s *Server) Init(log *utils.AppLogger) error
- func (s *Server) RequestIdMiddleware(c *gin.Context)
- func (s *Server) RouteApiConfirmPost(c *gin.Context)
- func (s *Server) RouteApiListGet(c *gin.Context)
- func (s *Server) RouteAuth(c *gin.Context)
- func (s *Server) RouteAuthConfirm(c *gin.Context)
- func (s *Server) RouteHealthzHandler(w http.ResponseWriter, r *http.Request)
- func (s *Server) RouteResult(c *gin.Context)
- func (s *Server) RouteWrapUnwrap(op requestOperation) gin.HandlerFunc
- func (s *Server) Start(ctx context.Context) error
Constants ¶
const ( OperationWrap requestOperation = iota OperationUnwrap )
const ( // Request is pending StatusPending requestStatus = iota // Request is completed and was successful StatusComplete // Request is completed and was canceled StatusCanceled // Request has been removed // This is only used in the public response StatusRemoved )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { TokenType string `json:"token_type"` Resource string `json:"resource"` Scope string `json:"scope"` ExpiresIn int `json:"expires_in"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` Error string `json:"error"` ErrorDescription string `json:"error_description"` }
AccessToken contains the details of the access token
type ErrorResponse ¶
type ErrorResponse string
ErrorResponse is used to send JSON responses with an error
const InternalServerError ErrorResponse = "An internal error occurred"
InternalServerError is an ErrorResponse for Internal Server Error messages
func (ErrorResponse) MarshalJSON ¶
func (e ErrorResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements a JSON marshaller that returns an object with the error key
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the server based on Gin
func (*Server) AccessTokenMiddleware ¶
AccessTokenMiddleware is a middleware that requires the user to be authenticated and present a cookie with the access token for Azure Key Vault This injects the token in the request's context if it exists and it's valid If required is true, the request fails if the token is not present
func (*Server) AllowIpMiddleware ¶
func (s *Server) AllowIpMiddleware() (gin.HandlerFunc, error)
AllowIpMiddleware is a middleware that allows requests from certain IPs only
func (*Server) RequestIdMiddleware ¶
RequestIdMiddleware is a middleware that generates a unique request ID for each request
func (*Server) RouteApiConfirmPost ¶
RouteApiConfirmPost is the handler for the POST /api/confirm request This receives the results of the confirm/reject action
func (*Server) RouteApiListGet ¶
RouteApiListGet is the handler for the GET /api/list request This returns the list of all pending requests If the Accept header is `application/x-ndjson`, then this sends a stream of records, updated as soon as they come in, using the NDJSON format (https://github.com/ndjson/ndjson-spec)
func (*Server) RouteAuth ¶
RouteAuth is the handler for the GET /auth request This redirects the user to the page where they can sign in
func (*Server) RouteAuthConfirm ¶
RouteAuthConfirm is the handler for the GET /auth/confirm request This exchanges an authorization code for an access token
func (*Server) RouteHealthzHandler ¶
func (s *Server) RouteHealthzHandler(w http.ResponseWriter, r *http.Request)
RouteHealthzHandler is the handler for the GET /healthz request as a http.Handler. It can be used to ping the server and ensure everything is working.
func (*Server) RouteResult ¶
RouteResult is the handler for the GET /result/:state request This can be invoked by the app to periodically poll for the result
func (*Server) RouteWrapUnwrap ¶
func (s *Server) RouteWrapUnwrap(op requestOperation) gin.HandlerFunc
RouteWrapUnwrap is the handler for the POST /wrap and /unwrap request