propellor/Propellor/Property/OpenId.hs

36 lines
1.0 KiB
Haskell
Raw Normal View History

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-13 15:58:22 +00:00
import Utility.FileMode
2014-04-08 20:58:11 +00:00
2014-04-08 21:29:56 +00:00
import Data.List
2014-04-13 15:58:22 +00:00
import System.Posix.Files
2014-04-08 21:29:56 +00:00
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
identfile u = combineProperties desc
[ File.hasPrivContent f
-- the identitites directory controls access, so open up
-- file mode
, File.mode f (combineModes (ownerWriteMode:readModes))
]
where
f = concat $ [ "/var/lib/simpleid/identities/", u, ".identity" ]