thentos-core-0.0.1.1: The swiss army knife of privacy-preserving identity management

Safe HaskellNone
LanguageHaskell2010

Thentos.Backend.Api.Proxy

Synopsis

Documentation

data ServiceProxy

Instances

HasServer * ServiceProxy 
type Foreign ServiceProxy = Req 
type ServerT * ServiceProxy m = Application 

reverseProxyHandler :: (Show e, Typeable e) => ProxyAdapter e -> ActionState -> Request -> IO WaiProxyResponse

Proxy or respond based on request headers.

data ProxyAdapter e

Allows adapting a proxy for a specific use case.

defaultRenderUser :: UserId -> User -> Action e () SBS

Render the user by showing their name.

prepareReq :: ProxyAdapter e -> RequestHeaders -> ByteString -> Request -> Request

data RqMod

Request modifier that contains all information that is needed to alter and forward an incoming request.

Constructors

RqMod ProxyUri RequestHeaders 

Instances

getRqMod :: ProxyAdapter e -> Request -> Action e () RqMod

Create request modifier with custom headers to add to it and the target URL of the proxied app to forward it to.

If the request contains a X-Thentos-Service header, we find the proxied app based on this header -- an error is thrown if the "proxies" section of the config doesn't match. Otherwise, the default proxied app from the "proxy" section of the config is used -- an error is thrown if that section is missing.

If the request contains a X-Thentos-Session header, we validate the session and set the X-Thentos-User and X-Thentos-Groups headers accordingly. Otherwise the request is forwarded as an anonymous request (no user logged in).

The first parameter allows adapting a proxy for a specific use case. To get the default behavior, use defaultProxyAdapter.

findTargetForServiceId :: ServiceId -> ThentosConfig -> Action e () (ServiceId, ProxyUri)

Look up the target URL for requests based on the given service ID. This requires a "proxies" section in the config. An error is thrown if this section is missing or doesn't contain a match. For convenience, both service ID and target URL are returned.

findDefaultServiceIdAndTarget :: ThentosConfig -> Action e () (ServiceId, ProxyUri)

Look up the service ID and target URL in the "proxy" section of the config. An error is thrown if that section is missing.

createCustomHeaders :: ProxyAdapter e -> Maybe ThentosSessionToken -> ServiceId -> Action e () RequestHeaders

Create headers identifying the user and their groups. Returns an empty list in case of an anonymous request.

err500onExc :: SomeException -> Application

Throw an internal server error if the proxied app is unreachable.