[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
|
class StagingAuthService
|
||||||
CONFIG_PATH = Rails.root.join("config", "basic_auth.yml")
|
|
||||||
|
|
||||||
def self.authenticate(username, password)
|
def self.authenticate(username, password)
|
||||||
if enabled?
|
if enabled?
|
||||||
username == config[:username] && password == config[:password]
|
username == Rails.application.secrets.basic_auth[:username] && password == Rails.application.secrets.basic_auth[:password]
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enabled?
|
def self.enabled?
|
||||||
!!config[:enabled]
|
ENV['BASIC_AUTH_ENABLED'] == 'enabled'
|
||||||
end
|
|
||||||
|
|
||||||
def self.config
|
|
||||||
if File.exist?(CONFIG_PATH)
|
|
||||||
YAML.safe_load(File.read(CONFIG_PATH)).symbolize_keys
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
# if you're sharing your code publicly.
|
# if you're sharing your code publicly.
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||||
|
basic_auth:
|
||||||
|
username: <%= ENV['BASIC_AUTH_USERNAME'] %>
|
||||||
|
password: <%= ENV['BASIC_AUTH_PASSWORD'] %>
|
||||||
france_connect_particulier:
|
france_connect_particulier:
|
||||||
identifier: <%= ENV['FC_PARTICULIER_ID'] %>
|
identifier: <%= ENV['FC_PARTICULIER_ID'] %>
|
||||||
secret: <%= ENV['FC_PARTICULIER_SECRET'] %>
|
secret: <%= ENV['FC_PARTICULIER_SECRET'] %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue