diff --git a/spec/commands/new_command_spec.cr b/spec/commands/new_command_spec.cr index 3cbb0c5..b4cf527 100644 --- a/spec/commands/new_command_spec.cr +++ b/spec/commands/new_command_spec.cr @@ -215,6 +215,11 @@ describe AmberCLI::Commands::NewCommand do config = YAML.parse(File.read(File.join(destination, "config/environments/development.yml"))) config["server"]["port"].as_i.should eq(3000) config["database"]["url"].as_s.should contain("sqlite3:") + %w[development test].each do |environment_name| + session_config = YAML.parse(File.read(File.join(destination, "config/environments/#{environment_name}.yml")))["session"] + session_config["store"].as_s.should eq("signed_cookie") + session_config["expires"].as_i.should eq(1_209_600) + end routes = File.read(File.join(destination, "config/routes.cr")) routes.should contain("pipeline :static") diff --git a/src/amber_cli/commands/new_command.cr b/src/amber_cli/commands/new_command.cr index 4338386..9bd96dc 100644 --- a/src/amber_cli/commands/new_command.cr +++ b/src/amber_cli/commands/new_command.cr @@ -682,9 +682,15 @@ database: session: key: "#{name}.session" + # signed_cookie keeps the session in the visitor's cookie: tamper-proof, readable by + # the visitor, about 4 KB, and nothing is held on the server. encrypted_cookie also + # hides it from the visitor. adapter keeps sessions on the server through `adapter`. store: "signed_cookie" + # Used only when store is adapter: memory (at most 10,000 sessions per process) or redis. adapter: "memory" - expires: 0 + # Seconds a session lasts after its last change (two weeks). 0 makes cookie sessions + # end when the browser closes and lets server-side sessions live until evicted. + expires: 1209600 logging: severity: "#{severity}" diff --git a/src/amber_cli/templates/app/config/environments/development.yml.ecr b/src/amber_cli/templates/app/config/environments/development.yml.ecr index 14220f2..0b48222 100644 --- a/src/amber_cli/templates/app/config/environments/development.yml.ecr +++ b/src/amber_cli/templates/app/config/environments/development.yml.ecr @@ -17,9 +17,15 @@ when "mysql" -%> session: key: <%= @name %>.session + # signed_cookie keeps the session in the visitor's cookie: tamper-proof, readable by + # the visitor, about 4 KB, and nothing is held on the server. encrypted_cookie also + # hides it from the visitor. adapter keeps sessions on the server through `adapter`. store: signed_cookie + # Used only when store is adapter: memory (at most 10,000 sessions per process) or redis. adapter: memory - expires: 0 + # Seconds a session lasts after its last change (two weeks). 0 makes cookie sessions + # end when the browser closes and lets server-side sessions live until evicted. + expires: 1209600 logging: severity: debug diff --git a/src/amber_cli/templates/app/config/environments/production.yml.ecr b/src/amber_cli/templates/app/config/environments/production.yml.ecr index 14309d4..b394efc 100644 --- a/src/amber_cli/templates/app/config/environments/production.yml.ecr +++ b/src/amber_cli/templates/app/config/environments/production.yml.ecr @@ -11,9 +11,15 @@ database: session: key: <%= @name %>.session + # signed_cookie keeps the session in the visitor's cookie: tamper-proof, readable by + # the visitor, about 4 KB, and nothing is held on the server. encrypted_cookie also + # hides it from the visitor. adapter keeps sessions on the server through `adapter`. store: signed_cookie + # Used only when store is adapter: memory (at most 10,000 sessions per process) or redis. adapter: memory - expires: 0 + # Seconds a session lasts after its last change (two weeks). 0 makes cookie sessions + # end when the browser closes and lets server-side sessions live until evicted. + expires: 1209600 logging: severity: info diff --git a/src/amber_cli/templates/app/config/environments/test.yml.ecr b/src/amber_cli/templates/app/config/environments/test.yml.ecr index 37d796b..3a70ef7 100644 --- a/src/amber_cli/templates/app/config/environments/test.yml.ecr +++ b/src/amber_cli/templates/app/config/environments/test.yml.ecr @@ -17,9 +17,15 @@ when "mysql" -%> session: key: <%= @name %>.session + # signed_cookie keeps the session in the visitor's cookie: tamper-proof, readable by + # the visitor, about 4 KB, and nothing is held on the server. encrypted_cookie also + # hides it from the visitor. adapter keeps sessions on the server through `adapter`. store: signed_cookie + # Used only when store is adapter: memory (at most 10,000 sessions per process) or redis. adapter: memory - expires: 0 + # Seconds a session lasts after its last change (two weeks). 0 makes cookie sessions + # end when the browser closes and lets server-side sessions live until evicted. + expires: 1209600 logging: severity: warn