mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 18:35:36 +08:00
Make API key auth togglable [SCI-6968]
This commit is contained in:
parent
2781295325
commit
eae0587699
4 changed files with 9 additions and 1 deletions
|
@ -21,6 +21,8 @@ module TokenAuthentication
|
|||
end
|
||||
|
||||
def authenticate_with_api_key
|
||||
return unless Rails.configuration.x.core_api_key_enabled
|
||||
|
||||
@api_key = request.headers['Api-Key']
|
||||
return unless @api_key
|
||||
|
||||
|
|
|
@ -629,6 +629,10 @@ class User < ApplicationRecord
|
|||
%w(id due_date age results status archived assigned tags comments)
|
||||
end
|
||||
|
||||
def api_key_enabled?
|
||||
Rails.configuration.x.core_api_key_enabled
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def confirmation_required?
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
<%= render partial: 'users/registrations/edit_partials/2fa' %>
|
||||
|
||||
<% if Rails.application.config.x.core_api_v1_enabled %>
|
||||
<% if current_user.api_key_enabled? %>
|
||||
<%= render partial: 'users/registrations/edit_partials/api_key' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -12,4 +12,6 @@ Rails.application.configure do
|
|||
config.x.core_api_v1_enabled = ENV['CORE_API_V1_ENABLED'] || false
|
||||
|
||||
config.x.core_api_v2_enabled = ENV['CORE_API_V2_ENABLED'] || false
|
||||
|
||||
config.x.core_api_key_enabled = ENV['CORE_API_KEY_ENABLED'] || false
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue