Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
c33a5906
Commit
c33a5906
authored
May 22, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4040 from smashwilson/generate-secret
Security: keep the Rails secret token out of version control.
parents
c5de01f8
e444c7f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
.gitignore
.gitignore
+1
-0
config/initializers/secret_token.rb
config/initializers/secret_token.rb
+17
-1
No files found.
.gitignore
View file @
c33a5906
...
...
@@ -29,3 +29,4 @@ db/data.yml
vendor/bundle/*
rails_best_practices_output.html
doc/code/*
.secret
config/initializers/secret_token.rb
View file @
c33a5906
# Be sure to restart your server when you modify this file.
require
'securerandom'
# Your secret key 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.
Gitlab
::
Application
.
config
.
secret_token
=
'0a38e9a40ca5d66d7002a6ade0ed0f8b71058c820163f66cf65d91521ab55255ff708b9909b138008a7f13d68fec575def1dc3ff7200cd72b065896315e0bed2'
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
Gitlab
::
Application
.
config
.
secret_token
=
find_secure_token
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment