-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#103 secret_token.rb methodology changed
- Loading branch information
Showing
4 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Be sure to restart your server when you modify this file. | ||
|
||
# Your secret key is used for verifying the integrity of signed cookies. | ||
# If you change this key, all old signed cookies will become invalid! | ||
|
||
# Make sure the secret is at least 30 characters and all random, | ||
# no regular words or you'll be exposed to dictionary attacks. | ||
# You can use `rake secret` to generate a secure secret key. | ||
|
||
# Make sure your secret_key_base is kept private | ||
# if you're sharing your code publicly. | ||
def find_secure_token | ||
token_file = Rails.root.join('.secret') | ||
if File.exist? token_file | ||
# Use the existing token. | ||
File.read(token_file).chomp | ||
else | ||
# Generate a new token of 64 random hexadecimal characters and store it in token_file. | ||
token = SecureRandom.hex(64) | ||
File.write(token_file, token) | ||
token | ||
end | ||
end | ||
|
||
<%= app_name.classify %>::Application.config.secret_key_base = find_secure_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c00cb14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍