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 23:31:03 +00:00
|
|
|
import qualified Propellor.Property.Service as Service
|
2014-04-08 20:58:11 +00:00
|
|
|
|
2014-04-08 21:29:56 +00:00
|
|
|
import Data.List
|
|
|
|
|
2014-04-08 21:51:10 +00:00
|
|
|
providerFor :: [UserName] -> String -> Property
|
2014-04-08 21:52:14 +00:00
|
|
|
providerFor users baseurl = propertyList desc $
|
2014-04-08 23:31:03 +00:00
|
|
|
[ Apt.serviceInstalledRunning "apache2"
|
2014-04-08 20:58:11 +00:00
|
|
|
, Apt.installed ["simpleid"]
|
2014-04-08 23:31:03 +00:00
|
|
|
`onChange` Service.restarted "apache2"
|
2014-04-08 21:52:14 +00:00
|
|
|
, File.fileProperty desc
|
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
|
2014-04-08 21:52:14 +00:00
|
|
|
url = "http://"++baseurl++"/simpleid"
|
|
|
|
desc = "openid provider " ++ url
|
2014-04-08 21:29:56 +00:00
|
|
|
setbaseurl l
|
|
|
|
| "SIMPLEID_BASE_URL" `isInfixOf` l =
|
2014-04-08 21:52:14 +00:00
|
|
|
"define('SIMPLEID_BASE_URL', '"++url++"');"
|
2014-04-08 21:29:56 +00:00
|
|
|
| otherwise = l
|
2014-04-13 15:58:22 +00:00
|
|
|
|
2014-04-13 16:21:43 +00:00
|
|
|
-- the identitites directory controls access, so open up
|
|
|
|
-- file mode
|
|
|
|
identfile u = File.hasPrivContentExposed $
|
|
|
|
concat $ [ "/var/lib/simpleid/identities/", u, ".identity" ]
|