File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 14
14
# Ignore all logfiles and tempfiles.
15
15
/log /* .log
16
16
/tmp
17
+
18
+ .DS_Store
19
+ .secret
Original file line number Diff line number Diff line change
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ require 'securerandom'
13
+
14
+ def secure_token
15
+ token_file = Rails . root . join ( '.secret' )
16
+ if File . exist? ( token_file )
17
+ # Use the existing token.
18
+ File . read ( token_file ) . chomp
19
+ else
20
+ # Generate a new token and store it in token_file.
21
+ token = SecureRandom . hex ( 64 )
22
+ File . write ( token_file , token )
23
+ token
24
+ end
25
+ end
26
+
27
+ SampleApp ::Application . config . secret_key_base = secure_token
You can’t perform that action at this time.
0 commit comments