Support Heimdal Kerberos.
This commit is contained in:
parent
3a7d5d3a05
commit
5c2f7bd4a6
@ -2,6 +2,42 @@
|
|||||||
|
|
||||||
> module Main where
|
> module Main where
|
||||||
> import Distribution.Simple
|
> import Distribution.Simple
|
||||||
|
> import System.Process (readProcessWithExitCode)
|
||||||
|
> import System.Exit (ExitCode(..))
|
||||||
|
> import System.Directory (removeFile)
|
||||||
|
> import System.IO.Error (try)
|
||||||
|
|
||||||
> main :: IO ()
|
> main :: IO ()
|
||||||
> main = defaultMain
|
> main = defaultMainWithHooks simpleUserHooks'
|
||||||
|
> where
|
||||||
|
> simpleUserHooks' = simpleUserHooks
|
||||||
|
> { postConf = postConf'
|
||||||
|
> , postClean = postClean'
|
||||||
|
> }
|
||||||
|
>
|
||||||
|
> postConf' x configFlags desc y = do
|
||||||
|
> hconf <- checkHeimKinit
|
||||||
|
> writeFile "config.h" $ concat
|
||||||
|
> [ "#ifndef CONFIG_H\n"
|
||||||
|
> , "#define CONFIG_H\n"
|
||||||
|
> , "\n"
|
||||||
|
> , "/* Define to 1 if you have Heimdal Kerberos. */\n"
|
||||||
|
> , hconf
|
||||||
|
> , "\n\n"
|
||||||
|
> , "#endif\n"
|
||||||
|
> ]
|
||||||
|
> let configFlags' = updateConfigFlags configFlags
|
||||||
|
> postConf simpleUserHooks x configFlags' desc y
|
||||||
|
> where
|
||||||
|
> updateConfigFlags configFlags = configFlags
|
||||||
|
>
|
||||||
|
> postClean' _ _ _ _ = do
|
||||||
|
> try . removeFile $ "config.h"
|
||||||
|
> return ()
|
||||||
|
>
|
||||||
|
> checkHeimKinit :: IO String
|
||||||
|
> checkHeimKinit = do
|
||||||
|
> (e,_,_) <- readProcessWithExitCode "kinit" ["--version"] ""
|
||||||
|
> if e == ExitSuccess then
|
||||||
|
> return "#define HAVE_HEIMDAL 1"
|
||||||
|
> else return "/* #undef HAVE_HEIMDAL */"
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
#include "../../config.h"
|
||||||
-- | Module for using a kerberos authentication service.
|
-- | Module for using a kerberos authentication service.
|
||||||
--
|
--
|
||||||
-- Please note that all configuration should have been done
|
-- Please note that all configuration should have been done
|
||||||
@ -65,7 +67,11 @@ loginKerberos username password = do
|
|||||||
fetch :: IO KerberosAuthResult
|
fetch :: IO KerberosAuthResult
|
||||||
fetch = do
|
fetch = do
|
||||||
(exitCode, _out, err) <- readProcessWithExitCode
|
(exitCode, _out, err) <- readProcessWithExitCode
|
||||||
|
#ifdef HAVE_HEIMDAL
|
||||||
|
"kinit" ["--password-file=STDIN", T.unpack username] (T.unpack password)
|
||||||
|
#else
|
||||||
"kinit" [T.unpack username] (T.unpack password)
|
"kinit" [T.unpack username] (T.unpack password)
|
||||||
|
#endif
|
||||||
case exitCode of
|
case exitCode of
|
||||||
ExitSuccess -> return Ok
|
ExitSuccess -> return Ok
|
||||||
ExitFailure x -> return $ interpretError x (T.pack err)
|
ExitFailure x -> return $ interpretError x (T.pack err)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ description: Kerberos authenticate.
|
|||||||
category: Web
|
category: Web
|
||||||
stability: Stable
|
stability: Stable
|
||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Custom
|
||||||
homepage: http://github.com/yesodweb/authenticate
|
homepage: http://github.com/yesodweb/authenticate
|
||||||
|
|
||||||
library
|
library
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user