mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 15:14:33 +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_ttl
|
||||||
attr_accessor :core_api_token_iss
|
attr_accessor :core_api_token_iss
|
||||||
attr_accessor :azure_ad_apps
|
attr_accessor :azure_ad_apps
|
||||||
|
attr_accessor :core_api_v1_preview
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@core_api_sign_alg = 'HS256'
|
@core_api_sign_alg = 'HS256'
|
||||||
@core_api_token_ttl = 30.minutes
|
@core_api_token_ttl = 30.minutes
|
||||||
@core_api_token_iss = 'SciNote'
|
@core_api_token_iss = 'SciNote'
|
||||||
@azure_ad_apps = {}
|
@azure_ad_apps = {}
|
||||||
|
@core_api_v1_preview = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,8 @@ Api.configure do |config|
|
||||||
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
|
config.core_api_token_iss = ENV['CORE_API_TOKEN_ISS']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.core_api_v1_preview = true if ENV['CORE_API_V1_PREVIEW']
|
||||||
|
|
||||||
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
||||||
vars.each do |name, value|
|
vars.each do |name, value|
|
||||||
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
||||||
|
|
|
@ -540,12 +540,14 @@ Rails.application.routes.draw do
|
||||||
get 'health', to: 'api#health'
|
get 'health', to: 'api#health'
|
||||||
get 'status', to: 'api#status'
|
get 'status', to: 'api#status'
|
||||||
post 'auth/token', to: 'api#authenticate'
|
post 'auth/token', to: 'api#authenticate'
|
||||||
|
if Api.configuration.core_api_v1_preview
|
||||||
namespace :v1 do
|
namespace :v1 do
|
||||||
resources :teams, only: %i(index show) do
|
resources :teams, only: %i(index show) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
constraints WopiSubdomain do
|
constraints WopiSubdomain do
|
||||||
# Office integration
|
# Office integration
|
||||||
|
|
|
@ -5,6 +5,9 @@ require 'database_cleaner'
|
||||||
require 'devise'
|
require 'devise'
|
||||||
require_relative 'support/controller_macros'
|
require_relative 'support/controller_macros'
|
||||||
ENV['RAILS_ENV'] = 'test'
|
ENV['RAILS_ENV'] = 'test'
|
||||||
|
|
||||||
|
ENV['CORE_API_V1_PREVIEW'] = 'true'
|
||||||
|
|
||||||
require File.expand_path('../../config/environment', __FILE__)
|
require File.expand_path('../../config/environment', __FILE__)
|
||||||
# Prevent database truncation if the environment is production
|
# Prevent database truncation if the environment is production
|
||||||
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
||||||
|
|
Loading…
Add table
Reference in a new issue