Documentation
¶
Overview ¶
Package tlsserver with TLS server for use by plugins and testing
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBearerToken ¶
GetBearerToken returns the bearer token from the HTTP request authorization header Returns an error if no token present or token isn't a bearer token
func WriteError ¶
func WriteError(w http.ResponseWriter, err error, code int)
WriteError is a convenience function that logs and writes an error If the reply has an error then write a bad request with the error as payload This also writes the StatusHeader containing StatusFailed.
func WriteReply ¶
func WriteReply( w http.ResponseWriter, handled bool, data any, err error)
WriteReply is a convenience function that serializes the data and writes it as a response, optionally reporting an error with code BadRequest.
when handled, this returns a 200 status code if no error is returned. handled is false means the request is in progress. This returns a 201. if an err is returned this returns a 400 bad request or 403 unauthorized error code the data can contain error details.
Types ¶
type TLSServer ¶
type TLSServer struct {
// contains filtered or unexported fields
}
TLSServer is a simple TLS MsgServer supporting BASIC, Jwt and client certificate authentication
func NewTLSServer ¶
func NewTLSServer(address string, port int, serverCert *tls.Certificate, caCert *x509.Certificate, ) (*TLSServer, *chi.Mux)
NewTLSServer creates a new TLS MsgServer instance with authentication support. This returns the chi-go router which can be used to add routes and middleware. This server supports the "message-id" header for received requests.
Use Start() to start listening.
The middleware handlers included with the server can be used for authentication.
address server listening address port listening port serverCert Server TLS certificate caCert CA certificate to verify client certificates
returns TLS server and router for handling requests
func (*TLSServer) Router ¶
Router returns the router for this server. This router has cors protection enabled.
func (*TLSServer) Start ¶
Start the TLS server using the provided CA and Server certificates. If a client certificate is provided it must be valid and signed by the CA. This configures handling of CORS requests to allow:
- any origin by returning the requested origin (not using wildcard '*').
- any method, eg PUT, POST, GET, PATCH,
- headers "Origin", "Accept", "Content-Type", "X-Requested-With"