define max age for store

This commit is contained in:
Umputun
2018-01-15 13:25:11 -06:00
parent adeaad991d
commit 4e6a15ad99
2 changed files with 15 additions and 12 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ Remark42 is a self-hosted, lightweight, and simple (yet functional) comment engi
#### Register oauth2 providers
Authentication handled by external providers. You should setup oauth2 for all (or some) of them in order to allow users to access comments. It is not mandatory to have all of them, but at least one should be property configured.
Authentication handled by external providers. You should setup oauth2 for all (or some) of them in order to allow users to make comments. It is not mandatory to have all of them, but at least one should be property configured.
##### Google Auth Provider
+14 -11
View File
@@ -67,7 +67,7 @@ func main() {
log.Fatalf("[ERROR] can't create directories, %+v", err)
}
dataStore := makeBoltStore()
dataStore := makeBoltStore(opts.Sites)
if p.Active != nil && p.Command.Find("import") == p.Active {
// import mode
@@ -85,20 +85,23 @@ func main() {
srvOpts := opts.ServerCommand
dataService := store.Service{Interface: dataStore, EditDuration: 5 * time.Minute}
sessionStore := sessions.NewFilesystemStore(srvOpts.SessionStore, []byte(srvOpts.StoreKey))
sessionStore.Options.HttpOnly = true
sessionStore := func() sessions.Store {
sess := sessions.NewFilesystemStore(srvOpts.SessionStore, []byte(srvOpts.StoreKey))
sess.Options.HttpOnly = true
sess.Options.MaxAge = 15 * 24 * 3600 // 15 days in seconds
sess.Options.Secure = true
return sess
}()
exporter := migrator.Remark{DataStore: dataStore}
authProviders := []auth.Provider{
auth.NewGoogle(auth.Params{
Cid: srvOpts.GoogleCID, Csecret: srvOpts.GoogleCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL,
}),
Cid: srvOpts.GoogleCID, Csecret: srvOpts.GoogleCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL}),
auth.NewGithub(auth.Params{
Cid: srvOpts.GithubCID, Csecret: srvOpts.GithubCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL,
}),
Cid: srvOpts.GithubCID, Csecret: srvOpts.GithubCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL}),
auth.NewFacebook(auth.Params{
Cid: srvOpts.FacebookCID, Csecret: srvOpts.FacebookCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL,
}),
Cid: srvOpts.FacebookCID, Csecret: srvOpts.FacebookCSEC, SessionStore: sessionStore, RemarkURL: opts.RemarkURL}),
}
srv := rest.Server{
@@ -130,9 +133,9 @@ func main() {
}
// makeBoltStore creates store for all sites
func makeBoltStore() store.Interface {
func makeBoltStore(siteNames []string) store.Interface {
sites := []store.BoltSite{}
for _, site := range opts.Sites {
for _, site := range siteNames {
sites = append(sites, store.BoltSite{SiteID: site, FileName: fmt.Sprintf("%s/%s.db", opts.BoltPath, site)})
}
result, err := store.NewBoltDB(sites...)