-
Notifications
You must be signed in to change notification settings - Fork 51
cleanup credentials #846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup credentials #846
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
user healthcheck on nopass -@all +cluster|info +ping | ||
user openc3 on >openc3password allkeys allchannels -@all +@read +@write +@pubsub +@connection +@transaction +info | ||
user scriptrunner on >scriptrunnerpassword resetkeys resetchannels ~running-script* ~*script-locks ~*script-breakpoints ~*openc3_log_messages &_action_cable_internal &script-api:* -@all +@read +@write +@pubsub +@hash +@connection | ||
user admin on >adminpassword +@admin | ||
user openc3 on #022bd57403439b2a3ec0c081cdd35d40a199bbd4ee6fc0e5113edd4fe1c10071 allkeys allchannels -@all +@read +@write +@pubsub +@connection +@transaction +info | ||
user scriptrunner on #e808c74e210256ee7cf3ec165271544167de776d526f7fa94243e5cdcc08b0c1 resetkeys resetchannels ~running-script* ~*script-locks ~*script-breakpoints ~*openc3_log_messages &_action_cable_internal &script-api:* -@all +@read +@write +@pubsub +@hash +@connection | ||
user admin on #749f09bade8aca755660eeb17792da880218d4fbdc4e25fbec279d7fe9f65d70 +@admin | ||
user default off |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ def _generate_url(microservice_name:, prefix:, schema: 'http', hostname: nil, po | |
# generate the auth object | ||
def _generate_auth | ||
if ENV['OPENC3_API_TOKEN'].nil? and ENV['OPENC3_API_USER'].nil? | ||
if ENV['OPENC3_API_PASSWORD'] || ENV['OPENC3_SERVICE_PASSWORD'] | ||
if ENV['OPENC3_API_PASSWORD'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really... at least it shouldn't have been. |
||
return OpenC3Authentication.new() | ||
else | ||
return nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,10 @@ | |
module OpenC3 | ||
class AuthModel | ||
PRIMARY_KEY = 'OPENC3__TOKEN' | ||
SERVICE_KEY = 'OPENC3__SERVICE__TOKEN' | ||
|
||
TOKEN_CACHE_TIMEOUT = 5 | ||
@@token_cache = nil | ||
@@token_cache_time = nil | ||
@@service_token_cache = nil | ||
@@service_token_cache_time = nil | ||
|
||
def self.is_set?(key = PRIMARY_KEY) | ||
Store.exists(key) == 1 | ||
|
@@ -43,20 +40,15 @@ def self.verify(token, permission: nil) | |
|
||
token_hash = hash(token) | ||
return true if @@token_cache and (Time.now - @@token_cache_time) < TOKEN_CACHE_TIMEOUT and @@token_cache == token_hash | ||
return true if @@service_token_cache and (Time.now - @@service_token_cache_time) < TOKEN_CACHE_TIMEOUT and @@service_token_cache == token_hash and permission != 'admin' | ||
|
||
@@token_cache = Store.get(PRIMARY_KEY) | ||
@@token_cache_time = Time.now | ||
return true if @@token_cache == token_hash | ||
|
||
@@service_token_cache = Store.get(SERVICE_KEY) | ||
@@service_token_cache_time = @@token_cache_time | ||
if ENV['OPENC3_SERVICE_PASSWORD'] and hash(ENV['OPENC3_SERVICE_PASSWORD']) != @@service_token_cache | ||
set_hash = hash(ENV['OPENC3_SERVICE_PASSWORD']) | ||
OpenC3::Store.set(SERVICE_KEY, set_hash) | ||
@@service_token_cache = set_hash | ||
end | ||
return true if @@service_token_cache == token_hash and permission != 'admin' | ||
# Handle a service password - Generally only used by ScriptRunner | ||
service_password = ENV['OPENC3_SERVICE_PASSWORD'] | ||
return true if service_password and service_password == token and permission != 'admin' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the point of the previous cache and how it is now removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This previous code was dumb. It should have just been comparing cleartext versions and not bothering with a hash. |
||
|
||
return false | ||
end | ||
|
||
|
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.
Who wins:
environment
orenv_file
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.
environment
https://docs.docker.com/compose/environment-variables/envvars-precedence/