set auth_token to a generated UUID if AUTH_TOKEN not passed in ENV#247
set auth_token to a generated UUID if AUTH_TOKEN not passed in ENV#247grahamb wants to merge 2 commits intoShopify:masterfrom grahamb:191-auth-token
Conversation
`require 'SecureRandom'` works on my OS X dev machine, but not on my linux deploy box. `require 'securerandom'` works on both.
|
@grahamb would this create a new token each time the app ran if you didn't set the env var? If so, that could be annoying for people during development and could cause integration issues in production. I really like the environment variable bit though! Maybe we should:
@pushmatrix what are your thoughts? |
|
use |
There was a problem hiding this comment.
ENV.fetch('AUTH_TOKEN') { SecureRandom.uuid }
There was a problem hiding this comment.
There are subtle differences...
@y = 0
def y
@y += 1
end
| Example | X is unset | X is anything | X is nil | unset, second call |
|---|---|---|---|---|
| `ENV["X"] | y` | 1 | {anything} | |
ENV.fetch("X") { y } |
1 | {anything} | nil | 2 |
ENV.fetch("X", y) |
1 | {anything} | nil | 1 |
|
I like this PR and the approach taken. Many people don't know how to use the auth token and this leaves their Dashing instances vulnerable to exploits. This PR would make them secure by default (random token). I do however prefer @kmayer's syntax but no need to open a block: That being said, @pseudomuto brings up a good point: that this would be a (small, but) breaking change. Not sure how to resolve that. |
Fixes issue #191. If an
AUTH_TOKENENV variable is not present, usesSecureRandom.uuidto generate a UUID to use as the token.AUTH_TOKEN='foobarbaz' dashing start→settings.auth_token == 'foobarbaz'dashing start→settings.auth_token == 'some-random-uuid-string'