Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class AuthProvider ap where
- data Provider where
- Provider :: AuthProvider p => p -> Provider
- data ProviderUrl = ProviderUrl [Text]
- data ProviderInfo = ProviderInfo {}
- type Providers = HashMap Text Provider
- type ProviderParser = (Text, Value -> Parser Provider)
- mkProviderParser :: forall ap. (FromJSON ap, AuthProvider ap) => Proxy ap -> ProviderParser
- parseProviders :: Object -> [ProviderParser] -> Result Providers
- data AuthUser = AuthUser {}
- type UserIdentity = ByteString
- mkRouteRender :: Maybe Text -> Text -> [Text] -> Render Provider
- providersTemplate :: Maybe Text -> Render Provider -> Providers -> Builder
Documentation
class AuthProvider ap where Source #
Core Authentication class, that allows for extensibility of the Auth
middleware created by mkAuthMiddleware
. Most
important function is handleLogin
, which implements the actual behavior of a
provider. It's function arguments in order:
- Current provider.ap
- Request made to the login pageRequest
[
- Url suffix, i.e. last part of the Url split byText
]'/'
character, for instance["login", "complete"]
suffix in the example below.
- Url renderer. It takes desired suffix as first argument and produces an absolute Url renderer. It can further be used to generate provider urls, for instance in Hamlet templates as will result inRender
ProviderUrl
"https://approot.com/_auth_middleware/providerName/login/complete?user=Hamlet"
or generate Urls for callbacks.@?{(ProviderUrl ["login", "complete"], [("user", Hamlet)])}
(
- Action to call on a successfull login.UserIdentity
->IO
Response
)(
- Should be called in case of a failure with login process by supplying a status and a short error message.Status
->ByteString
->IO
Response
)
getProviderName :: ap -> Text Source #
Return a name for the provider. It will be used as a unique identifier
for this provider. Argument should not be evaluated, as there are many
places were undefined
value is passed to this function.
Since: 0.1.0
getProviderInfo :: ap -> ProviderInfo Source #
Get info about the provider. It will be used in rendering the web page with a list of providers.
Since: 0.1.0
handleLogin :: ap -> Request -> [Text] -> Render ProviderUrl -> (UserIdentity -> IO Response) -> (Status -> ByteString -> IO Response) -> IO Response Source #
Handle a login request in a custom manner. Can be used to render a login page with a form or redirect to some other authentication service like OpenID or OAuth2.
Since: 0.1.0
Provider
Generic authentication provider wrapper.
Provider :: AuthProvider p => p -> Provider |
data ProviderInfo Source #
Provider information used for rendering a page with list of supported providers.
Provider Parsing
type ProviderParser = (Text, Value -> Parser Provider) Source #
Aeson parser for a provider with unique provider name (same as returned by
getProviderName
)
mkProviderParser :: forall ap. (FromJSON ap, AuthProvider ap) => Proxy ap -> ProviderParser Source #
First argument is not evaluated and is only needed for restricting the type.
parseProviders :: Object -> [ProviderParser] -> Result Providers Source #
Parse configuration for providers from an Object
.
User
Representation of a user for a particular Provider
.
type UserIdentity = ByteString Source #
An arbitrary user identifer, eg. a username or an email address.