content: {-
   Copyright 2022-23, Juspay India Pvt Ltd
  
   This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License
  
   as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program
  
   is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  
   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of
  
   the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
  -}
  
  module Tools.Auth where
  
  import Kernel.Prelude
  import Kernel.Types.Id
  import Kernel.Utils.Monitoring.Prometheus.Servant
  import Kernel.Utils.Servant.HeaderAuth
  import Servant hiding (Context)
  
  -- | Performs simple token verification.
  type TokenAuth = HeaderAuth "token" VerifyToken
  
  data VerifyToken = VerifyToken
  
  instance
    SanitizedUrl (sub :: Type) =>
    SanitizedUrl (TokenAuth :> sub)
    where
    getSanitizedUrl _ = getSanitizedUrl (Proxy :: Proxy sub)
  
  -- TODO: make common Person across all our BAPs
  data Person
  
  type PersonId = Id Person
  
  instance VerificationMethod VerifyToken where
    type VerificationResult VerifyToken = PersonId
    verificationDescription =
      "Checks whether token is registered.\
      \If you don't have a token, use registration endpoints."
  