vikunja-api-0.24.6.0: lib/Vikunja/API/Auth.hs
{-
Vikunja API
# Pagination Every endpoint capable of pagination will return two headers: * `x-pagination-total-pages`: The total number of available pages for this request * `x-pagination-result-count`: The number of items returned for this request. # Rights All endpoints which return a single item (project, task, etc.) - no array - will also return a `x-max-right` header with the max right the user has on this item as an int where `0` is `Read Only`, `1` is `Read & Write` and `2` is `Admin`. This can be used to show or hide ui elements based on the rights the user has. # Errors All errors have an error code and a human-readable error message in addition to the http status code. You should always check for the status code in the response, not only the http status code. Due to limitations in the swagger library we're using for this document, only one error per http status code is documented here. Make sure to check the [error docs](https://vikunja.io/docs/errors/) in Vikunja's documentation for a full list of available error codes. # Authorization **JWT-Auth:** Main authorization method, used for most of the requests. Needs `Authorization: Bearer <jwt-token>`-header to authenticate successfully. **API Token:** You can create scoped API tokens for your user and use the token to make authenticated requests in the context of that user. The token must be provided via an `Authorization: Bearer <token>` header, similar to jwt auth. See the documentation for the `api` group to manage token creation and revocation. **BasicAuth:** Only used when requesting tasks via CalDAV. <!-- ReDoc-Inject: <security-definitions> -->
OpenAPI Version: 3.0.1
Vikunja API API version: 0.24.6
Contact: hello@vikunja.io
Generated by OpenAPI Generator (https://openapi-generator.tech)
-}
{-|
Module : Vikunja.API.Auth
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
module Vikunja.API.Auth where
import Vikunja.Core
import Vikunja.MimeTypes
import Vikunja.Model as M
import qualified Data.Aeson as A
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
import qualified Data.Foldable as P
import qualified Data.Map as Map
import qualified Data.Maybe as P
import qualified Data.Proxy as P (Proxy(..))
import qualified Data.Set as Set
import qualified Data.String as P
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TL
import qualified Data.Time as TI
import qualified Network.HTTP.Client.MultipartFormData as NH
import qualified Network.HTTP.Media as ME
import qualified Network.HTTP.Types as NH
import qualified Web.FormUrlEncoded as WH
import qualified Web.HttpApiData as WH
import Data.Text (Text)
import GHC.Base ((<|>))
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
import qualified Prelude as P
-- * Operations
-- ** Auth
-- *** getTokenOpenid
-- | @POST \/auth\/openid\/{provider}\/callback@
--
-- Authenticate a user with OpenID Connect
--
-- After a redirect from the OpenID Connect provider to the frontend has been made with the authentication `code`, this endpoint can be used to obtain a jwt token for that user and thus log them in.
--
-- AuthMethod: 'AuthApiKeyJWTKeyAuth'
--
getTokenOpenid
:: (Consumes GetTokenOpenid MimeJSON, MimeRender MimeJSON OpenidCallback)
=> OpenidCallback -- ^ "callback" - The openid callback
-> Provider -- ^ "provider" - The OpenID Connect provider key as returned by the /info endpoint
-> VikunjaRequest GetTokenOpenid MimeJSON AuthToken MimeJSON
getTokenOpenid callback (Provider provider) =
_mkRequest "POST" ["/auth/openid/",toPath provider,"/callback"]
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyJWTKeyAuth)
`setBodyParam` callback
data GetTokenOpenid
-- | /Body Param/ "callback" - The openid callback
instance HasBodyParam GetTokenOpenid OpenidCallback
-- | @application/json@
instance Consumes GetTokenOpenid MimeJSON
-- | @application/json@
instance Produces GetTokenOpenid MimeJSON
-- *** loginPost
-- | @POST \/login@
--
-- Login
--
-- Logs a user in. Returns a JWT-Token to authenticate further requests.
--
loginPost
:: (Consumes LoginPost MimeJSON, MimeRender MimeJSON UserLogin)
=> UserLogin -- ^ "credentials" - The login credentials
-> VikunjaRequest LoginPost MimeJSON AuthToken MimeJSON
loginPost credentials =
_mkRequest "POST" ["/login"]
`setBodyParam` credentials
data LoginPost
-- | /Body Param/ "credentials" - The login credentials
instance HasBodyParam LoginPost UserLogin
-- | @application/json@
instance Consumes LoginPost MimeJSON
-- | @application/json@
instance Produces LoginPost MimeJSON
-- *** registerPost
-- | @POST \/register@
--
-- Register
--
-- Creates a new user account.
--
registerPost
:: (Consumes RegisterPost MimeJSON, MimeRender MimeJSON UserAPIUserPassword)
=> UserAPIUserPassword -- ^ "credentials" - The user credentials
-> VikunjaRequest RegisterPost MimeJSON UserUser MimeJSON
registerPost credentials =
_mkRequest "POST" ["/register"]
`setBodyParam` credentials
data RegisterPost
-- | /Body Param/ "credentials" - The user credentials
instance HasBodyParam RegisterPost UserAPIUserPassword
-- | @application/json@
instance Consumes RegisterPost MimeJSON
-- | @application/json@
instance Produces RegisterPost MimeJSON