Documentation
¶
Overview ¶
Package proxy implements a proxy server that forwards http requests with iShare Bearer tokens.
The requests need to provide the extra information in the HTTP headers. The headers are specified as constants.
A typical request requires the headers
X-Ishare-Adapter-Key: some-very-secret-key X-Ishare-Server-Eori: 00000000001 X-Ishare-Token-Url: scheme.ishare.net X-Ishare-Service-Url: http://scheme.ishare.net/capabilities
When a client wants to send a get request to e.g. https://scheme.ishare.net/capabilities, then it needs to provide the parameters in the headers as shown above.
The proxy clones the request except for the headers shown above, and sends it to the url passed in "X-Ishare-Server-Resource".
The server caches the iShare capable clients to limit the token requests.
Index ¶
- Constants
- func DecodeContent(h http.Header, body []byte) ([]byte, error)
- func GUnzip(d []byte) ([]byte, error)
- func HasContentEncoding(h http.Header, encoding string) bool
- func HasContentType(header http.Header, typeSubtype string) bool
- func HeadersKV(h http.Header) []any
- func IsContentType(value string, typeSubtype string) bool
- type Server
Constants ¶
const ( // HeaderAPIKey is the header for the apiKey HeaderAPIKey = "X-Ishare-Adapter-Key" // HeaderTokenURL is the header name that must contain the base url of the server. // It is used in the iShare Config. HeaderTokenURL = "X-Ishare-Token-Url" // HeaderServerEORI contains the EORI of the server. HeaderServerEORI = "X-Ishare-Server-Eori" // HeaderResource contains the resource the client wants to send the request to. // This must be a valid url. HeaderServiceURL = "X-Ishare-Service-Url" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct { // handler holds the *http.ServeMux // contains filtered or unexported fields }
A Server implements the proxy.
func New ¶
New creates a new proxy server.
addr is the addres that the proxy will listen on.
apiKey, if specified, protects the adapter with an api key that must be specified in the X-Ishare-Adapter-Key header.
log specifies the zap sugared logger. Can be nil for no logging.
icfg must be an isharecredentials.Config, see below
icfg is used as a template, the following fields are used:
ClientEORI
Cert
Key
CACerts
RootCerts
TokenBackdate