Commit 72a69ce2 authored by Michael Hanus 's avatar Michael Hanus

Adds private data dir to generated Spicey application

parent 1146d499
--- Some global configurations for the Spicey application.
module Config.Spicey
where
--- Location of the directory containing private run-time data
--- such as session and authentication information.
spiceyDataDir :: String
spiceyDataDir = "data"
...@@ -74,6 +74,8 @@ deploy: checkdeploy ...@@ -74,6 +74,8 @@ deploy: checkdeploy
$(CPM) exec $(MAKECGI) -standalone -m main -o $(WEBSERVERDIR)/spicey.cgi Main.curry $(CPM) exec $(MAKECGI) -standalone -m main -o $(WEBSERVERDIR)/spicey.cgi Main.curry
# copy other files (style sheets, images,...) # copy other files (style sheets, images,...)
cp -r public/* $(WEBSERVERDIR) cp -r public/* $(WEBSERVERDIR)
mkdir -p $(WEBSERVERDIR)/data # create private data dir
cp -p data/htaccess $(WEBSERVERDIR)/data/.htaccess # and make it private
chmod -R go+rX $(WEBSERVERDIR) chmod -R go+rX $(WEBSERVERDIR)
# clean up generated the package directory # clean up generated the package directory
......
...@@ -13,11 +13,14 @@ module System.Session ( ...@@ -13,11 +13,14 @@ module System.Session (
getSessionData, putSessionData, removeSessionData getSessionData, putSessionData, removeSessionData
) where ) where
import HTML.Base import FilePath ( (</>) )
import Time
import Global import Global
import List import List
import Time
import HTML.Base
import Config.Spicey ( spiceyDataDir )
import System.Crypto import System.Crypto
--- The life span in minutes to store data in sessions. --- The life span in minutes to store data in sessions.
...@@ -32,7 +35,7 @@ sessionCookieName = "spiceySessionId" ...@@ -32,7 +35,7 @@ sessionCookieName = "spiceySessionId"
--- This global value saves time and last session id. --- This global value saves time and last session id.
lastId :: Global (Int, Int) lastId :: Global (Int, Int)
lastId = global (0, 0) (Persistent sessionCookieName) lastId = global (0, 0) (Persistent (spiceyDataDir </> sessionCookieName))
--- The abstract type to represent session identifiers. --- The abstract type to represent session identifiers.
......
...@@ -14,7 +14,11 @@ module System.SessionInfo ( ...@@ -14,7 +14,11 @@ module System.SessionInfo (
getUserSessionInfo, updateUserSessionInfo getUserSessionInfo, updateUserSessionInfo
) where ) where
import FilePath ( (</>) )
import Global import Global
import Config.Spicey ( spiceyDataDir )
import System.Session import System.Session
-------------------------------------------------------------------------- --------------------------------------------------------------------------
...@@ -39,7 +43,8 @@ setUserLoginOfSession login (SD _) = SD login ...@@ -39,7 +43,8 @@ setUserLoginOfSession login (SD _) = SD login
-------------------------------------------------------------------------- --------------------------------------------------------------------------
--- Definition of the session state to store the login name (as a string). --- Definition of the session state to store the login name (as a string).
userSessionInfo :: Global (SessionStore UserSessionInfo) userSessionInfo :: Global (SessionStore UserSessionInfo)
userSessionInfo = global emptySessionStore (Persistent "userSessionInfo") userSessionInfo =
global emptySessionStore (Persistent (spiceyDataDir </> "userSessionInfo"))
--- Gets the data of the current user session. --- Gets the data of the current user session.
getUserSessionInfo :: IO UserSessionInfo getUserSessionInfo :: IO UserSessionInfo
......
AuthType Basic
AuthName Spicey
AuthUserFile /dev/null
AuthGroupFile /dev/null
<Limit GET>
<IfVersion < 2.3>
# old access rules
order deny,allow
deny from all
satisfy any
#allow from 127.0.0.
</IfVersion>
<IfVersion >= 2.3>
# new access rules via authz_mod_core
Require all denied
#Require local
</IfVersion>
</Limit>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"synopsis": "Web application 'XXXPKGNAMEXXX' generated by Spicey", "synopsis": "Web application 'XXXPKGNAMEXXX' generated by Spicey",
"category": [ "Web" ], "category": [ "Web" ],
"dependencies": { "dependencies": {
"base" : ">= 1.0.0, < 2.0.0",
"cdbi" : ">= 2.0.0", "cdbi" : ">= 2.0.0",
"html" : ">= 2.1.0", "html" : ">= 2.1.0",
"wui" : ">= 2.0.0" "wui" : ">= 2.0.0"
......
...@@ -16,7 +16,7 @@ import Spicey.Scaffolding ...@@ -16,7 +16,7 @@ import Spicey.Scaffolding
systemBanner :: String systemBanner :: String
systemBanner = systemBanner =
let bannerText = "Spicey Web Framework (Version " ++ packageVersion ++ let bannerText = "Spicey Web Framework (Version " ++ packageVersion ++
" of 24/11/18)" " of 25/11/18)"
bannerLine = take (length bannerText) (repeat '-') bannerLine = take (length bannerText) (repeat '-')
in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine
...@@ -55,18 +55,22 @@ spiceyStructure pkgname = ...@@ -55,18 +55,22 @@ spiceyStructure pkgname =
ResourceFile NoExec "Processes.curry", ResourceFile NoExec "Processes.curry",
GeneratedFromERD createAuthorizations ], GeneratedFromERD createAuthorizations ],
Directory "View" [ Directory "View" [
ResourceFile NoExec ("View" </> "SpiceySystem.curry"), ResourceFile NoExec $ "View" </> "SpiceySystem.curry",
GeneratedFromERD createViews, GeneratedFromERD createViews,
GeneratedFromERD createHtmlHelpers ], GeneratedFromERD createHtmlHelpers ],
Directory "Controller" [ Directory "Controller" [
ResourceFile NoExec ("Controller" </> "SpiceySystem.curry"), ResourceFile NoExec $ "Controller" </> "SpiceySystem.curry",
GeneratedFromERD createControllers ], GeneratedFromERD createControllers ],
Directory "Model" [ Directory "Model" [
GeneratedFromERD createModels ], GeneratedFromERD createModels ],
Directory "Config" [ Directory "Config" [
ResourceFile NoExec "UserProcesses.curry", ResourceFile NoExec $ "Config" </> "Spicey.curry",
ResourceFile NoExec $ "Config" </> "UserProcesses.curry",
GeneratedFromERD createRoutes ] GeneratedFromERD createRoutes ]
], ],
Directory "data" [
ResourceFile NoExec $ "data" </> "htaccess"
],
Directory "public" [ Directory "public" [
ResourceFile NoExec "index.html", ResourceFile NoExec "index.html",
ResourceFile NoExec "favicon.ico", ResourceFile NoExec "favicon.ico",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment