2014-04-08 20:58:11 +00:00
|
|
|
module Propellor.Property.OpenId where
|
|
|
|
|
|
|
|
import Propellor
|
|
|
|
import qualified Propellor.Property.File as File
|
|
|
|
import qualified Propellor.Property.Apt as Apt
|
|
|
|
|
2014-04-08 21:29:56 +00:00
|
|
|
import Data.List
|
|
|
|
|
2014-04-08 21:51:10 +00:00
|
|
|
providerFor :: [UserName] -> String -> Property
|
|
|
|
providerFor users baseurl = propertyList ("openid provider") $
|
2014-04-08 20:58:11 +00:00
|
|
|
[ serviceRunning "apache2"
|
|
|
|
`requires` Apt.installed ["apache2"]
|
|
|
|
, Apt.installed ["simpleid"]
|
2014-04-08 21:10:52 +00:00
|
|
|
`onChange` serviceRestarted "apache2"
|
2014-04-08 21:51:10 +00:00
|
|
|
, File.fileProperty ("simpleid host " ++ baseurl)
|
2014-04-08 21:29:56 +00:00
|
|
|
(map setbaseurl) "/etc/simpleid/config.inc"
|
2014-04-08 20:58:11 +00:00
|
|
|
] ++ map identfile users
|
|
|
|
where
|
|
|
|
identfile u = File.hasPrivContent $ concat
|
|
|
|
[ "/var/lib/simpleid/identities/", u, ".identity" ]
|
2014-04-08 21:29:56 +00:00
|
|
|
setbaseurl l
|
|
|
|
| "SIMPLEID_BASE_URL" `isInfixOf` l =
|
2014-04-08 21:51:10 +00:00
|
|
|
"define('SIMPLEID_BASE_URL', 'http://"++baseurl++"/simpleid');"
|
2014-04-08 21:29:56 +00:00
|
|
|
| otherwise = l
|