[ENV] Basic auth config
This commit is contained in:
parent
aa0a4cf87f
commit
d37958d1ae
2 changed files with 5 additions and 12 deletions
|
@ -1,23 +1,13 @@
|
|||
class StagingAuthService
|
||||
CONFIG_PATH = Rails.root.join("config", "basic_auth.yml")
|
||||
|
||||
def self.authenticate(username, password)
|
||||
if enabled?
|
||||
username == config[:username] && password == config[:password]
|
||||
username == Rails.application.secrets.basic_auth[:username] && password == Rails.application.secrets.basic_auth[:password]
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def self.enabled?
|
||||
!!config[:enabled]
|
||||
end
|
||||
|
||||
def self.config
|
||||
if File.exist?(CONFIG_PATH)
|
||||
YAML.safe_load(File.read(CONFIG_PATH)).symbolize_keys
|
||||
else
|
||||
{}
|
||||
end
|
||||
ENV['BASIC_AUTH_ENABLED'] == 'enabled'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
# if you're sharing your code publicly.
|
||||
defaults: &defaults
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
basic_auth:
|
||||
username: <%= ENV['BASIC_AUTH_USERNAME'] %>
|
||||
password: <%= ENV['BASIC_AUTH_PASSWORD'] %>
|
||||
france_connect_particulier:
|
||||
identifier: <%= ENV['FC_PARTICULIER_ID'] %>
|
||||
secret: <%= ENV['FC_PARTICULIER_SECRET'] %>
|
||||
|
|
Loading…
Reference in a new issue