mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-11 09:26:37 +08:00
Merge pull request #1281 from okriuchykhin/ok_SCI_2686
Make API V1 togglable [SCI-2686]
This commit is contained in:
commit
10a650c3c5
4 changed files with 11 additions and 2 deletions
|
@ -16,12 +16,14 @@ module Api
|
|||
attr_accessor :core_api_token_ttl
|
||||
attr_accessor :core_api_token_iss
|
||||
attr_accessor :azure_ad_apps
|
||||
attr_accessor :core_api_v1_preview
|
||||
|
||||
def initialize
|
||||
@core_api_sign_alg = 'HS256'
|
||||
@core_api_token_ttl = 30.minutes
|
||||
@core_api_token_iss = 'SciNote'
|
||||
@azure_ad_apps = {}
|
||||
@core_api_v1_preview = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@ Api.configure do |config|
|
|||
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
|
||||
end
|
||||
|
||||
config.core_api_v1_preview = true if ENV['CORE_API_V1_PREVIEW']
|
||||
|
||||
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
||||
vars.each do |name, value|
|
||||
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
||||
|
|
|
@ -540,8 +540,10 @@ Rails.application.routes.draw do
|
|||
get 'health', to: 'api#health'
|
||||
get 'status', to: 'api#status'
|
||||
post 'auth/token', to: 'api#authenticate'
|
||||
namespace :v1 do
|
||||
resources :teams, only: %i(index show) do
|
||||
if Api.configuration.core_api_v1_preview
|
||||
namespace :v1 do
|
||||
resources :teams, only: %i(index show) do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,9 @@ require 'database_cleaner'
|
|||
require 'devise'
|
||||
require_relative 'support/controller_macros'
|
||||
ENV['RAILS_ENV'] = 'test'
|
||||
|
||||
ENV['CORE_API_V1_PREVIEW'] = 'true'
|
||||
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
# Prevent database truncation if the environment is production
|
||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
||||
|
|
Loading…
Reference in a new issue