Initial commit

This commit is contained in:
Yaser
2026-08-13 19:56:46 +03:30
commit de1d57a67b
474 changed files with 43185 additions and 0 deletions

49
config/abilities.yml Normal file
View File

@@ -0,0 +1,49 @@
roles:
- superadmin
- admin
- compliance
- support
admin_permissions:
superadmin:
manage:
- User
- Activity
- Ability
- APIKey
- Profile
- Permission
- Label
- Restriction
- Level
- Document
admin:
read:
- Activity
- Level
- APIKey
- Permission
- Document
manage:
- User
- Activity
- Profile
- Label
- Document
compliance:
read:
- Level
- User
- Activity
manage:
- Label
update:
- Profile
support:
read:
- User
- Activity
- APIKey
- Profile
- Label
- Level

111
config/amqp.yml Normal file
View File

@@ -0,0 +1,111 @@
connect:
host: <%= ENV.fetch('BARONG_EVENT_API_RABBITMQ_HOST', 'localhost') %>
port: <%= ENV.fetch('RABBITMQ_PORT', '5672') %>
username: <%= ENV.fetch('RABBITMQ_USER', 'guest') %>
password: <%= ENV.fetch('RABBITMQ_PASSWORD', 'guest') %>
exchange:
trade:
name: peatio.trade
type: headers
notification:
name: peatio.notification
type: direct
orderbook:
name: peatio.orderbook
type: fanout
events:
name: peatio.events
type: direct
matching:
name: peatio.matching
type: direct
finex-spot:
name: finex.orderapi
type: direct
opendax:
name: finex.orderapi
type: direct
queue:
matching:
name: peatio.matching
durable: true
# You can set queue maximum length (see https://www.rabbitmq.com/maxlength.html).
# For order matching queue it is recommended to set limit about to 10000 per market.
# So in case you have 10 markets you would set 1000000. But this value is relative and depends on your business (market load).
#
# max_length: 10000
#
# Alternatively you can pass custom arguments here (for example in case your use RabbitMQ plugins):
#
# arguments:
# x-max-length: 10000
#
# When you change any parameter of queue definition it is required to drop it in RabbitMQ admin panel.
# In case you want this to be done transparently and automatically I recommend to set auto_delete to true.
#
# auto_delete: true
#
# In such case queue will be deleted automatically once all workers are disconnected. This should ensure queue
# is created from scratch with new configuration at next redeployment.
new_trade:
name: peatio.trade.new
durable: true
order_processor:
name: peatio.order.processor
durable: true
market_ticker:
name: peatio.trade.market_ticker
pusher_market:
name: peatio.pusher.market
pusher_member:
name: peatio.pusher.member
withdraw_coin:
name: peatio.withdraw.coin
deposit_collection_fees:
name: peatio.deposit.collection_fees
deposit_collection:
name: peatio.deposit.collection
deposit_coin_address:
name: peatio.deposit.coin.address
durable: true
influx_writer:
name: peatio.trade.writer
trade_error:
name: peatio.trades.errors
# Queue which used by third-party trading engine for updating balances and
# order submit consuming.
events_processor:
name: peatio.events.processor
binding:
matching:
queue: matching
clean_start: true
exchange: matching
trade_executor:
queue: new_trade
exchange: matching
order_processor:
queue: order_processor
exchange: matching
withdraw_coin:
queue: withdraw_coin
deposit_coin_address:
queue: deposit_coin_address
influx_writer:
queue: influx_writer
exchange: trade
trade_error:
queue: trade_error
exchange: matching
events_processor:
queue: events_processor
exchange: events
channel:
trade_executor:
prefetch: 5
order_processor:
prefetch: 5

40
config/application.rb Normal file
View File

@@ -0,0 +1,40 @@
# frozen_string_literal: true
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Barong
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
# Configure Sentry as early as possible.
if ENV["BARONG_SENTRY_DSN_BACKEND"].present?
require "sentry-raven"
Raven.configure { |config| config.dsn = ENV["BARONG_SENTRY_DSN_BACKEND"] }
end
# Adding Grape API
# Eager loading all app/ folder
config.eager_load_paths += Dir[Rails.root.join('app')]
config.eager_load_paths += Dir[Rails.root.join('lib/barong')]
# Setup the logger
config.logger = Logger.new(STDOUT)
# Load lib folder files to be visible in specs
config.paths.add 'lib', eager_load: false, autoload: true
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
#
env_file = File.join(Rails.root, 'barong.env')
Dotenv.load(env_file) if File.exists?(env_file)
end
end

18
config/authz_rules.yml Normal file
View File

@@ -0,0 +1,18 @@
#
# pass for whitelisted (public) routes
# block for blacklisted routes
#
rules:
pass:
- api/v2/barong/public
- api/v2/barong/identity
- api/v2/peatio/public
- api/v2/peatio/coinmarketcap
- api/v2/peatio/coingecko
- api/v2/ranger/public
- api/v2/applogic/public
- api/v2/arke/public
- api/v2/finex/public
block:
- api/v2/barong/management
- api/v2/peatio/management

76
config/backend.yml Normal file
View File

@@ -0,0 +1,76 @@
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "3306:3306"
redis:
image: redis:4.0
volumes:
- redis_data:/data
ports:
- "6379:6379"
vault:
image: vault:0.11.4
ports:
- "8200:8200"
environment:
SKIP_SETCAP: 1
VAULT_TOKEN: changeme
VAULT_DEV_ROOT_TOKEN_ID: changeme
VAULT_ADDR: http://vault:8200
gateway:
image: quay.io/datawire/ambassador:0.40.0
ports:
- "8080:80"
volumes:
- ./gateway:/ambassador/ambassador-config/:ro
entrypoint:
- sh
- -exc
- |
# Allow accessing host's 0.0.0.0 so we can connect to a local peatio
# from the gateway container
ip -4 route list match 0/0 | awk '{print $$3" barong.local"}' >> /etc/hosts
# Continue with the default entrypoint
./entrypoint.sh
minio:
image: minio/minio
volumes:
- minio-data:/data
ports:
- "9000:9000"
environment:
MINIO_ACCESS_KEY: changemeEXAMPLE
MINIO_SECRET_KEY: changemeEXAMPLEKEY
command: server /data
rabbitmq:
image: rabbitmq:3.7.6-management
volumes:
- rabbitmq_data:/var/lib/rabbitmq
ports:
- "5672:5672"
- "15672:15672"
mailcatcher:
image: schickling/mailcatcher
ports:
- "1080:1080"
- "1025:1025"
volumes:
db_data:
redis_data:
rabbitmq_data:
minio-data:

53
config/barong.yml Normal file
View File

@@ -0,0 +1,53 @@
activation_requirements:
email: 'verified'
state_triggers:
banned:
- ban
- fraud
deleted:
- delete
locked:
- suspicious
- lock
document_types:
- Passport
- Identity card
- Driver license
- Utility Bill
- Residental
- Institutional
- Poa
- Selfie
document_categories:
- front_side
- selfie
- back_side
user_storage_titles:
# - personal ## example
# - company ## example
captcha_protected_endpoints:
- user_create
- session_create
- password_reset
- email_confirmation
profile_verification_roles:
- superadmin
# - admin
# - kyc_worker
kyc_levels:
1:
2: profile
3: access_phone
4: card
5: iban
2:
6: poa
7: telephone
8: selfie
9: owner_phone
3:
10: vip

4
config/boot.rb Normal file
View File

@@ -0,0 +1,4 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

10
config/cable.yml Normal file
View File

@@ -0,0 +1,10 @@
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: <%= ENV.fetch("BARONG_REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: barong_production

View File

@@ -0,0 +1 @@
I6tY6I6n09+uAR8G6yiX24k+SKHfx0ZTISnXmX9kupVSymzL02I41OiGqH5qWOvwmLpdvrr/BSIcqDms1tMSzgei+6IGZNyuY+nIwG9rTce33ucrMUS+9/RH8MFaSGyi7k04K3dWgf0/b/9xm9Qcv3dK7mnB46MwbsDRXf0gwbxS9YcgDzdRA5nXlgrQn/hTxwIHv4I8k6FCa9FFvrywCtVql1guo6RIzvm+iAYmHa3Ef89twIYaCUFNhJXknEUHleCCLLpWSqQ7B0gPauerlTrv+yJByPaDin1CsbNbMeykgZoL0WewauicKzQB52LWNSC0i+6cLa98XWmLiSDQDy2OsuQ+pOr0J3UzYhoj5LhiikT71sisLrRRr6CjBsIfN6Gh7SSThjnvquqpkelGlJERtsdgJFyF2ayOTUkIviKL1KaH+xF+dliTQKNfFrrA5fDQKl0vIfTwCuOGZXSnF7xHrj98kLk4Z62hQe2mhk4fznK907d+sHXd7Sdo4mZr2Mz4M9KCN7Ez734pQ1ua0cB2mOwj7x4P7Z5HLpw+AcGEnZegqJ/ZbEgvhaRx227lSh49LpIr62kH7RJi00e6gOPOJuETwRvOCD6wmb0y55n1kISoKQIX+zQui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QElbFQFoS5MLbGhWLzkMpyiRPCZrT5r8SGPdtwqEKXNF2RVWFsOvXsDicv2mv09nb4ppFem7jgwGwj0Wi2Mv7x7ZxAW/EKt1fWTtVdMgse8wJZnbOAn4Xl5G/ll3m6jytmG4rHdy6HEQL56gEYencQViWFbuqJYsPZDRTOuc6vwngTgqaoNpGC/UpbaCOxwurjw0+wszsjKtF9YC/aIxddAypHwmAA/zq/gbLpwAyilI8K8ZDUcHQbH14vubz5Kn65SQv44VbwOe4k6HPrnkWjrEN+IOukv0NJhIcln0yOBwAjru4q2A1aNmeJaoCPpmqMb+95/vC5BNKyFJnyr6of9bDIlNdQABH8vBzFwyUcPN+SXCZbRDiDmL4+Iw4lNxfV2XGDCob3K9Jh2Fo85xsNUkCuVsvU5iBD9YoctB+oWcGd5mDFNJsX0M+Ft5rBbznYv/syk8lurM27L1RWKMz6KbGEQoK4ov2Jz+PlkxrX7WzznolxXtwEGZdU2LeVbqUj5HGYnntWDjoF9AASLLFDo7V67wyHu9ZL+YXEOVgsAbNjJfyqJInmPMdGHyjHpBXqGse+l44qBPsI2fwdj0NbkkFM+sScBrx9S3gfVB3iOOUcHo5MkvbmsauTRwwg67YzhMTbFGSSjiX4QI5iwDP--JL81g7CbhrdSINC1--OBdY+ZocetafB3jJoROfRA==

20
config/database.yml Normal file
View File

@@ -0,0 +1,20 @@
default: &default
adapter: <%= ENV.fetch('DATABASE_ADAPTER', 'mysql2') %>
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 6).to_i * ENV.fetch("WEB_CONCURRENCY", 1).to_i %>
host: <%= ENV.fetch('DATABASE_HOST', '127.0.0.1') %>
port: <%= ENV.fetch('DATABASE_PORT', 3306) %>
username: <%= ENV.fetch('DATABASE_USER', 'root') %>
password: <%= ENV.fetch('DATABASE_PASS', 'changeme') %>
development:
<<: *default
database: barong_development
test:
<<: *default
database: barong_test
production:
<<: *default
database: <%= ENV.fetch('DATABASE_NAME', 'barong_production') %>

5
config/environment.rb Normal file
View File

@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View File

@@ -0,0 +1,63 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Standard rails dev caching behaviour
# if Rails.root.join('tmp', 'caching-dev.txt').exist?
# config.action_controller.perform_caching = true
# config.cache_store = :memory_store
# config.public_file_server.headers = {
# 'Cache-Control' => "public, max-age=#{2.days.to_i}"
# }
# else
# config.action_controller.perform_caching = false
# config.cache_store = :null_store
# end
# Using cache for sessions and permissions forces to use redis cache_store as mandatory store
# Here we use ENV.fetch instead of Barong::App.config, because environment/* files loads before lib and initializers
config.cache_store = :redis_cache_store, { driver: :hiredis, url: ENV.fetch('BARONG_REDIS_URL', 'redis://localhost:6379/1') }
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.web_console.whitelisted_ips = '172.0.0.0/16'
end

View File

@@ -0,0 +1,106 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = ENV.fetch('LOG_LEVEL', 'info')
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Using cache for sessions and permissions forces to use redis cache_store as mandatory store
# Here we use ENV.fetch instead of Barong::App.config, because environment/* files loads before lib and initializers
if ENV.true?('BARONG_REDIS_CLUSTER')
config.cache_store = :redis_cache_store, { driver: :hiredis, cluster: [ENV.fetch('BARONG_REDIS_URL')], password: ENV.fetch('BARONG_REDIS_PASSWORD') }
else
config.cache_store = :redis_cache_store, { driver: :hiredis, url: ENV.fetch('BARONG_REDIS_URL', 'redis://localhost:6379/1') }
end
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "barong_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = true
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = JSONLogFormatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
output = STDERR if ENV["RAILS_LOG_TO_STDERR"].present?
output = STDOUT if ENV["RAILS_LOG_TO_STDOUT"].present?
unless output.nil?
logger = ActiveSupport::Logger.new(output)
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.logger.formatter = config.log_formatter
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

View File

@@ -0,0 +1,46 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.log_level = :fatal
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Store uploaded files on the local file system in a temporary directory
config.active_storage.service = :test
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@@ -0,0 +1,27 @@
ApiPagination.configure do |config|
# If you have more than one gem included, you can choose a paginator.
config.paginator = :kaminari # or :will_paginate
# By default, this is set to 'Total'
# config.total_header = 'X-Total'
# By default, this is set to 'Per-Page'
# config.per_page_header = 'X-Per-Page'
# Optional: set this to add a header with the current page number.
config.page_header = 'Page'
# Optional: set this to add other response format. Useful with tools that define :jsonapi format
# config.response_formats = [:json, :xml, :jsonapi]
# Optional: what parameter should be used to set the page option
config.page_param = :page
# Optional: what parameter should be used to set the per page option
config.per_page_param = :limit
# Optional: Include the total and last_page link header
# By default, this is set to true
# Note: When using kaminari, this prevents the count call to the database
# config.include_total = false
end

View File

@@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

View File

@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@@ -0,0 +1,157 @@
# frozen_string_literal: true
# 1/ check if ENV key exist then validate and set
# 2/ if no check in credentials then validate and set
# 3/ if no generate display warning, raise error in production, and set
require 'barong/app'
require 'barong/keystore'
require 'barong/string'
private_key_path = ENV['JWT_PRIVATE_KEY_PATH']
if !private_key_path.nil?
pkey = Barong::KeyStore.open!(private_key_path)
Rails.logger.error('Loading private key from: ' + private_key_path)
elsif Rails.application.credentials.has?(:private_key)
pkey = Barong::KeyStore.read!(Rails.application.credentials.private_key)
Rails.logger.info('Loading private key from credentials.yml.enc')
elsif !Rails.env.production?
# Generates private key
key = Barong::KeyStore.generate
pkey = key.to_pem
pub_key = key.public_key.to_pem
# Save private/public keys
Barong::KeyStore.save!(pkey, 'config/rsa-key')
Barong::KeyStore.save!(pub_key, 'config/rsa-key.pub')
Rails.logger.warn('Warning !! Generating private key')
else
raise 'Private key not found or invalid'
end
kstore = Barong::KeyStore.new(pkey)
# Define default value for secret_key_base in test and development mode
ENV['SECRET_KEY_BASE'] = '' unless Rails.env.production?
Barong::App.define do |config|
# General configuration ---------------------------------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#general-configuration
config.set(:app_name, 'Fibitex')
config.set(:domain, 'fibitex.com')
config.set(:uid_prefix, 'ID', regex: /^[A-z]{2,6}$/)
config.set(:session_name, '_dalan_session')
config.set(:session_expire_time, '1800', type: :integer)
config.set(:kyc_provider, 'kycaid', values: %w[kycaid local])
config.set(:required_docs_expire, 'false', type: :bool)
config.set(:doc_num_limit, '10', type: :integer)
config.set(:geoip_lang, 'en', values: %w[en de es fr ja ru])
config.set(:csrf_protection, 'true', type: :bool)
config.set(:apikey_nonce_lifetime, '50000', type: :integer)
config.set(:gateway, 'cloudflare', values: %w[akamai cloudflare])
config.set(:jwt_expire_time, '3600', type: :integer)
config.set(:profile_double_verification, 'false', type: :bool)
config.set(:crc32_salt, '')
config.set(:api_data_masking_enabled, 'true', type: :bool)
config.set(:first_registration_superadmin, 'true', type: :bool)
config.set(:mgn_api_keys_user, 'false', type: :bool)
config.set(:mgn_api_keys_sa, 'false', type: :bool)
# Password configuration -----------------------------------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#password-configuration
config.set(:password_regexp, '^(?=.*[[:lower:]])(?=.*[[:upper:]])(?=.*[[:digit:]])(?=.*[[:graph:]]).{8,80}$', type: :regexp)
config.set(:password_min_entropy, '14', type: :integer)
config.set(:password_use_dictionary, 'true', type: :bool)
# CAPTCHA configuration ---------------------------------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#captcha-configuration
config.set(:captcha, 'none', values: %w[none recaptcha geetest])
config.set(:geetest_id, '')
config.set(:geetest_key, '')
config.set(:recaptcha_site_key, '')
config.set(:recaptcha_secret_key, '')
# Dependencies configuration (vault, redis, rabbitmq) ---------------
# https://www.openware.com/sdk/docs/barong/configuration.html#dependencies-configuration-vault-redis-rabbitmq
config.set(:event_api_rabbitmq_host, 'localhost')
config.set(:event_api_rabbitmq_port, '5672')
config.set(:event_api_rabbitmq_username, 'guest')
config.set(:event_api_rabbitmq_password, 'guest')
config.set(:vault_address, 'http://localhost:8200')
config.set(:vault_token, '')
config.set(:redis_cluster, 'false', type: :bool)
config.set(:redis_url, 'redis://localhost:6379/1')
config.set(:redis_password, '')
config.set(:vault_app_name, 'barong')
# CORS configuration -----------------------------------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#api-cors-configuration
config.set(:api_cors_origins, '*')
config.set(:api_cors_max_age, '3600')
config.set(:api_cors_allow_credentials, 'false', type: :bool)
# Config files configuration ----------------------------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#config-files-configuration
config.set(:config, 'config/barong.yml', type: :path)
config.set(:maxminddb_path, 'geolite/GeoLite2-Country.mmdb', type: :path)
config.set(:seeds_file, Rails.root.join('config', 'seeds.yml'), type: :path)
config.set(:authz_rules_file, Rails.root.join('config', 'authz_rules.yml'), type: :path)
# SMTP configuration ------------------------------------------------
# https://github.com/openware/barong/blob/master/docs/general/env_configuration.md#smtp-configuration
config.set(:sender_email, 'noreply@barong.io')
config.set(:sender_name, 'Barong')
config.set(:smtp_password, '')
config.set(:smtp_port, 1025)
config.set(:smtp_host, 'localhost')
config.set(:smtp_user, '')
config.set(:smtp_logo_link, 'https://storage.cloud.google.com/public_peatio/logo.png')
config.set(:default_language, 'en')
config.set(:smtp_domain, 'test.com')
config.set(:smtp_enable_starttls_auto, 'true', type: :bool)
config.set(:smtp_openssl_verify_mode, 'peer')
config.set(:smtp_auth, 'plain')
# KYCAID ------------------------------------------------------------
config.set(:kycaid_authorization_token, '')
config.set(:kycaid_sandbox_mode, 'true', type: :bool)
config.set(:kycaid_api_endpoint, 'https://api.kycaid.com/')
# Auth0 configuration -----------------------------------------------
config.set(:auth0_domain, '')
config.set(:auth0_client_id, '')
# jibit configuration ----------------------------------------
config.set(:jibit_api_url, '')
config.set(:jibit_api_key, '')
config.set(:jibit_api_secret, '')
end
# KYCAID configuring
KYCAID.configure do |config|
config.authorization_token = Barong::App.config.kycaid_authorization_token
config.sandbox_mode = Barong::App.config.kycaid_sandbox_mode
config.api_endpoint = Barong::App.config.kycaid_api_endpoint
end
ActionMailer::Base.smtp_settings = {
address: Barong::App.config.smtp_host,
port: Barong::App.config.smtp_port,
user_name: Barong::App.config.smtp_user,
authentication: Barong::App.config.smtp_auth,
domain: Barong::App.config.smtp_domain,
enable_starttls_auto: Barong::App.config.smtp_enable_starttls_auto,
openssl_verify_mode: Barong::App.config.smtp_openssl_verify_mode,
password: Barong::App.config.smtp_password
}
Barong::GeoIP.lang = Barong::App.config.geoip_lang
Rails.application.config.x.keystore = kstore
Barong::App.config.keystore = kstore

View File

@@ -0,0 +1,17 @@
# FIXME BarongConfig should be a feature of Barong::App
class BarongConfig
class << self
def list
@hash ||= read_from_yaml
end
private
def read_from_yaml
conf = YAML.load_file(Barong::App.config.config)
conf['activation_requirements'] = {'email' => 'verified'} unless conf['activation_requirements']
conf
end
end
end

View File

@@ -0,0 +1,60 @@
# frozen_string_literal: true
require 'carrierwave/storage/abstract'
require 'carrierwave/storage/file'
require 'carrierwave/storage/fog'
Barong::App.define do |config|
# Storage configuration
# https://www.openware.com/sdk/docs/barong/configuration.html#storage-configuration
config.set(:storage_provider, 'local')
config.set(:storage_bucket_name, 'local')
config.set(:storage_access_key, '')
config.set(:storage_secret_key, '')
config.set(:storage_endpoint, '') # optional (AWS, AliCloud)
config.set(:storage_signature_version, '4') # optional (AWS)
config.set(:storage_region, '') # optional (AWS, AliCloud)
config.set(:storage_pathstyle, 'false', type: :bool) # optional (AWS, AliCloud)
# Carrierwave defaults configuration
config.write(:uploader, UploadUploader)
config.set(:upload_size_min_range, '1', type: :integer) # in megabytes
config.set(:upload_size_max_range, '10', type: :integer) # in megabytes
config.set(:upload_auth_url_expiration, '1', type: :integer) # in minutes
config.set(:upload_extension_whitelist, 'jpg, jpeg, png, pdf', type: :array)
end
CarrierWave.configure do |config|
if 'Google'.casecmp?(Barong::App.config.storage_provider)
config.fog_credentials = {
provider: 'Google',
google_storage_access_key_id: Barong::App.config.storage_access_key,
google_storage_secret_access_key: Barong::App.config.storage_secret_key
}
config.fog_directory = Barong::App.config.storage_bucket_name
elsif 'AWS'.casecmp?(Barong::App.config.storage_provider)
config.fog_credentials = {
provider: 'AWS',
aws_signature_version: Barong::App.config.storage_signature_version,
aws_access_key_id: Barong::App.config.storage_access_key,
aws_secret_access_key: Barong::App.config.storage_secret_key,
region: Barong::App.config.storage_region,
endpoint: Barong::App.config.storage_endpoint,
path_style: Barong::App.config.storage_pathstyle
}
config.fog_directory = Barong::App.config.storage_bucket_name
elsif 'AliCloud'.casecmp?(Barong::App.config.storage_provider)
Barong::App.write(:uploader, AliUploader)
config.fog_credentials = {
provider: 'aliyun',
aliyun_accesskey_id: Barong::App.config.storage_access_key,
aliyun_accesskey_secret: Barong::App.config.storage_secret_key,
aliyun_oss_bucket: Barong::App.config.storage_bucket_name,
aliyun_region_id: Barong::App.config.storage_region,
aliyun_oss_endpoint: "oss-#{Barong::App.config.storage_region}.aliyuncs.com"
}
config.fog_directory = Barong::App.config.storage_bucket_name
else
config.storage :file
end
end

View File

@@ -0,0 +1,25 @@
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
# Rails.application.config.content_security_policy_report_only = true

View File

@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.signed_cookie_digest = 'SHA256'
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
# document types definitions
class DocumentTypes
class << self
def list
@list ||= YAML.load_file(Barong::App.config.config)['document_types']
end
def category_list
@category_list ||= YAML.load_file(Barong::App.config.config)['document_categories']
end
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
require_dependency 'barong/event_api'
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.include ::EventAPI::ActiveRecord::Extension
end

View File

@@ -0,0 +1,25 @@
def catch_and_report_exception(options = {})
begin
yield
nil
rescue options.fetch(:class) { StandardError } => e
report_exception(e)
e
end
end
def report_exception(exception, report_to_ets = true)
report_exception_to_screen(exception)
report_exception_to_ets(exception) if report_to_ets
end
def report_exception_to_screen(exception)
Rails.logger.unknown exception.inspect
Rails.logger.unknown exception.backtrace.join("\n") if exception.respond_to?(:backtrace)
end
def report_exception_to_ets(exception)
Raven.capture_exception(exception) if defined?(Raven)
rescue => ets_exception
report_exception(ets_exception, false)
end

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += %i[password upload]

View File

@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@@ -0,0 +1,26 @@
require 'yaml'
require 'openssl'
(YAML.load_file('config/management_api.yml') || {}).deep_symbolize_keys!.tap do |x|
x.fetch(:keychain).each do |id, key|
key = OpenSSL::PKey.read(Base64.urlsafe_decode64(key.fetch(:value)))
if key.private?
raise ArgumentError, 'keychain.' + id.to_s + ' was set to private key, ' \
'however it should be public (in config/management_api.yml).'
end
x[:keychain][id][:value] = key
end
x.fetch(:scopes).values.each do |scope|
%i[permitted_signers mandatory_signers].each do |list|
scope[list] = scope.fetch(list, []).map(&:to_sym)
scope[list] = scope.fetch(list, []).map(&:to_sym)
if list == :mandatory_signers && scope[list].empty?
raise ArgumentError, 'scopes.' + scope.to_s + '.' + list.to_s + ' is empty, ' \
'however it should contain at least one value (in config/management_api.yml).'
end
end
end
API::V2::Management::JWTAuthenticationMiddleware.security_configuration = x
end

View File

@@ -0,0 +1,18 @@
KaveRestApi.configure do |config|
# To completely ignore debug mode events(No Errors) uncomment this line *optional
# config.debugmode = false #by default it's true
# It is recommended that you pull your API keys from environment settings. *required
config.api_key = ENV.fetch("KAVENEGAR_API_KEY", 'changeme')
# Default response format is json (you can use xml too). *optional
config.format = 'json'
#If you don't set your sender number in your request, this is the default number used instead *required
config.default_sender = ENV.fetch("KAVENEGAR_SENDER", 'changeme')
# You can remove problematic emojis (like android emojis) and replace with standard emojis listed here:(https://www.webpagefx.com/tools/emoji-cheat-sheet/)
# config.strip_emoji = 'false' # can include false , true and matcher
end

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@@ -0,0 +1,4 @@
# Don't allow downloaded files to be created as StringIO. Create a tempfile instead
OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
OpenURI::Buffer.const_set 'StringMax', 0

View File

@@ -0,0 +1,50 @@
# frozen_string_literal: true
require_dependency 'barong/mock_sms'
Barong::App.define do |config|
# Twilio configuration ----------------------
# https://www.openware.com/sdk/docs/barong/configuration.html#twilio-configuration
# config.write(:twilio_provider, TwilioSmsSendService)
# config.set(:phone_verification, 'mock')
# config.set(:twilio_phone_number, '+15005550000')
# config.set(:twilio_account_sid, '')
# config.set(:twilio_auth_token, '')
# config.set(:twilio_service_sid, '')
# config.set(:sms_content_template, 'Your verification code for Barong: {{code}}')
end
# sid = Barong::App.config.twilio_account_sid
# token = Barong::App.config.twilio_auth_token
# service_sid = Barong::App.config.twilio_service_sid
# case Barong::App.config.phone_verification
# when 'twilio_sms'
# raise 'Invalid twilio config' if sid.to_s.empty? || token.to_s.empty?
# client = Twilio::REST::Client.new(sid, token)
# Barong::App.write(:twilio_provider, TwilioSmsSendService)
# when 'twilio_verify'
# raise 'Invalid twilio config' if sid.to_s.empty? || token.to_s.empty?
# client = Twilio::REST::Client.new(sid, token)
# service = client.verify.services.create(friendly_name: Barong::App.config.app_name) unless service_sid.present?
# Barong::App.write(:twilio_provider, TwilioVerifyService)
# when 'mock'
# if Rails.env.production?
# Rails.logger.info("WARNING! Don't use mock phone verification service in production")
# end
# Barong::App.write(:twilio_provider, MockPhoneVerifyService)
# else
# raise "Unknown phone verification service #{Barong::App.config.phone_verification}"
# end
# Barong::App.set(:twilio_client, client) if client
# Barong::App.set(:twilio_service_sid, service.sid) if service
# Phonelib.strict_check = true

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
begin
if Rails.env.production?
redis_url = ENV.fetch('BARONG_REDIS_URL', 'redis://localhost:6379/1')
r = Redis.new(url: redis_url)
r.ping
end
rescue Redis::CannotConnectError
Rails.logger.fatal("Error connecting to Redis on #{redis_url} (Errno::ECONNREFUSED)")
raise 'FATAL: connection to Redis refused'
end

View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
module Rack
module Session
# redis store configuration class to act as session_store (cache_store)
class Redis
def set_session(env, session_id, new_session, options)
with_lock env, false do
with do |c|
new_options = if env['api_v2.session_lifetime']
x = ActionDispatch::Request::Session::Options.new \
options.instance_variable_get(:@by),
options.instance_variable_get(:@env),
options.instance_variable_get(:@delegate)
x[:expire_after] = env['api_v2.session_lifetime']
x
else
options
end
c.set(session_id, new_session, new_options)
end
session_id
end
end
end
end
end

View File

@@ -0,0 +1,4 @@
# frozen_string_literal: true
# Use cache_store as session_store for Rails sessions. Key default is '_barong_session'
Rails.application.config.session_store :cache_store, key: Barong::App.config.session_name, expire_after: 24.hours.seconds

View File

@@ -0,0 +1,9 @@
# frozen_string_literal: true
Sidekiq.configure_server do |config|
config.redis = { url: ENV.fetch('BARONG_REDIS_URL', 'redis://localhost:6379/1') }
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV.fetch('BARONG_REDIS_URL', 'redis://localhost:6379/1') }
end

View File

@@ -0,0 +1,8 @@
# Extend default list of trusted proxies with generic private and cloudflare proxy list
# Cloudflare proxies list
# config/cloudflare_ips.yml fetches every time you build an image. Check Dockerfile l54, l55
cloudflare_ips = File.read('config/cloudflare_ips.yml').split(/\R+/)
extend_proxies = cloudflare_ips.map { |proxy| IPAddr.new(proxy) }
Rails.application.config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + extend_proxies

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
# whitelisted data storage titles definitions
class UserStorageTitles
class << self
def list
@list ||= YAML.load_file(Barong::App.config.config)['user_storage_titles'] || []
end
end
end

View File

@@ -0,0 +1,42 @@
# frozen_string_literal: true
require 'vault/rails'
Vault::Rails.configure do |config|
config.enabled = Rails.env.production?
config.address = Barong::App.config.vault_address
config.token = Barong::App.config.vault_token
config.ssl_verify = false
config.timeout = 60
config.application = Barong::App.config.vault_app_name
end
if Barong::App.config.vault_token.to_s != ''
def renew_process
token = Vault.auth_token.lookup(Vault.token)
time = token.data[:ttl] * (1 + rand) * 0.1
Rails.logger.debug '[VAULT] Token will renew in %.0f sec' % time
sleep(time)
Vault.auth_token.renew(token.data[:id])
Rails.logger.info '[VAULT] Token renewed'
end
# where connect to vault
token = Vault.auth_token.lookup(Vault.token)
if token.data[:renewable]
Rails.logger.info '[VAULT] Starting token renew thread'
Thread.new do
loop do
renew_process
rescue StandardError => e
report_exception(e)
sleep 60
end
end
else
Rails.logger.info '[VAULT] Token is not renewable'
end
else
Rails.logger.warn 'Environment variable BARONG_VAULT_TOKEN is missing'
end

View File

@@ -0,0 +1,12 @@
# encoding: UTF-8
# frozen_string_literal: true
# This file is auto-generated from the current state of VCS.
# Instead of editing this file, please use bin/gendocs.
module Barong
class Application
GIT_TAG = '2.7.0'
GIT_SHA = '3d7fe81'
BUILD_DATE = '2020-12-08 15:09:53+02:00'
VERSION = GIT_TAG
end
end

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

33
config/locales/en.yml Normal file
View File

@@ -0,0 +1,33 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@@ -0,0 +1,54 @@
# Be sure to restart your server when you modify this file.
#
# This file keeps all the security configuration variables for «Management API v1».
#
# Keeps all the public keys used to validate signatures.
# All values must be presented in PEM format and be URL-safe Base64 encoded.
#
# Example:
#
# keychain:
# backend-1.mycompany.example:
# algorithm: RS256
# value: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF3UjNPT1RQbzZvZE8wM3hXVDRNawp6TXJuM2pQS2pVdW0rVkc5dUZWODZNejVnMm1ueXdSRDc4MEY4aXVaZm41SGtROFpTUlFHYlRHNnB1dlVWWDFCClA0MWIrUW52VHFtWFhHcE9aSklzV3V2cHA4dHpZenFOejUvcTRRdUZQWDlrczdtaVV2dkNzbmo5S21Wb08yMU4KUVgyOWZUNkRJYldkUnJvWU1IOHloVmRrSjRVQnhYeHlSWmZ4VnN4UFVwckNodEgxN1JwNnQvYVRTR0VZNndQNwpKbEVCZi9Gb0djQk15OU5BOWhqZFMyMWxGcmVYeXdaUzZYdmhrN3dydGJWT2didU5EajdVeWhjS0RCaHA4c2VjCkV4TlB6d2p4ckhGTzhZaitFejBCMmZKQ1FDWW9SVG1kTzVEQS9kRTFHQmtqeXRCZjhDdGVIdExXcmZIU2g5em0KNlFJREFRQUIKLS0tLS1FTkQgUFVCT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RyaXQwSktVYwphb25jTXJ0RlB2WlRuZjZROUhVM2VpR3NxTHhWczVZRTBGUlVsd0Z4TjZzbnZNQW9rNEpRT3A5cUExUi96WHMwCnRWdUVpeEJ1Sm5jSjZSYlp5UVp5YWg3YzAxd1NLcks1UTRudVh3VlhXUkhvd0gxOTZHMU9TODhoYmVZNHNneTkKdForZ3NsdlZIYWJmK1JqK0JtZmNOYmx2T1lQWlI4K3dVQ2pOWW43L1BWRjQ0NDRzUCtTZkEyejdvaU1OVStrVwpGVHM5dVdRNGxzQ0RIQnd6ZXNFMDc0dmZLMHF4c0NNN0hWeHhVc2gvNGx3aGppZTgrTFNqdzliWTlrcjJxWWFmClRMRnpoVWl2clJMaEpWdnZkQmRRYlBIUFVybnJ2TnFqblRYOWtFcWR4bktrbWluWmhtbU1pakpKa1dGREgwbmgKNmR4ZlZwZ2puYXUzWmoyZkNSNFV6aXNXK25MaExUc1Fadzd0b0NaVUo2aWV6N0psOEpJYWdBVWJ5OW8ycUN4ZgpWcTBwK3pwRlZKUFZzelVQNkZMTzh3Tjd5aThVT3l4T3VmdmEvOHgySmRJTzJ4emlPc2ZLVnhIZTFZRkZtWVdtCnZKaWZ1ZGUrdCtBbS9EM1FMSjlpK2JNQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
#
#
keychain: {}
#
# Keeps all the JWT verification options.
# The documentation is available at https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names.
# Check lib/jwt/default_options.rb for the default options.
#
jwt: {}
#
# Keep all the API security scopes.
#
# The API security scope consists of scope name, list of permitted and mandatory signers.
# The scope name is associated with API actions. For example, write_labels is associated with
# ability to create private labels, edit and remove them. The scopes which have «write» in the name are supposed
# to be dangerous so they must require more signatures then read-only scopes
#
# Each scope must include list of permitted and mandatory signers.
# Barong validates JWT signatures against permitted keys and doesn't trust
# JWTs which don't include signatures from all mandatory signers.
#
# Example:
#
# scopes:
# write_labels:
# permitted_signers: ['backend-1.mycompany.example', 'backend-2.mycompany.example']
# mandatory_signers: ['backend-1.mycompany.example', 'backend-2.mycompany.example']
#
# The available scopes include:
# write_labels
# - otp_sign
#
scopes: {}

22
config/plugins.yml Normal file
View File

@@ -0,0 +1,22 @@
# Be sure to run "bin/install_plugins" when you modify this file.
#
# This file is used for listing Barong plugins.
# The plugins must be listed as an array. Each element of array described the plugin using the next variables:
#
# * name
# Mandatory. Specify plugin name. The name must be compatible with filesystem rules.
#
# * git
# Mandatory. Specify Git repository URL.
#
# * commit
# Mandatory. Specify commit hash which Barong will checkout via "bin/install_plugins".
#
# * require
# Optional. Specify relative path to file from vendor/plugins which should be required by Barong.
# You may set this value to "false" if you don't want Barong to require the plugin.
# Example configuration:
#- name: peatio-plugin-example
# git: https://github.com/rubykube/peatio-plugin-example.git
# commit: 11edd2e7c0bef229516f42fde79615a68a008d45

37
config/puma.rb Normal file
View File

@@ -0,0 +1,37 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { 1 }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 6 }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

4
config/routes.rb Normal file
View File

@@ -0,0 +1,4 @@
Rails.application.routes.draw do
match '/api/v2/auth/*path', to: AuthorizeController.action(:authorize), via: :all
mount API::Base, at: '/api'
end

6
config/spring.rb Normal file
View File

@@ -0,0 +1,6 @@
%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
].each { |path| Spring.watch(path) }

34
config/storage.yml Normal file
View File

@@ -0,0 +1,34 @@
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]

View File

@@ -0,0 +1,54 @@
# Be sure to restart your server when you modify this file.
#
# This file keeps all the security configuration variables for «Management API v1».
#
# Keeps all the public keys used to validate signatures.
# All values must be presented in PEM format and be URL-safe Base64 encoded.
#
# Example:
#
# keychain:
# backend-1.mycompany.example:
# algorithm: RS256
# value: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF3UjNPT1RQbzZvZE8wM3hXVDRNawp6TXJuM2pQS2pVdW0rVkc5dUZWODZNejVnMm1ueXdSRDc4MEY4aXVaZm41SGtROFpTUlFHYlRHNnB1d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IFBVQkxJQyBLRVktLS0tLQo=
#
#
keychain: {}
#
# Keeps all the JWT verification options.
# The documentation is available at https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names.
# Check lib/jwt/default_options.rb for the default options.
#
jwt: {}
#
# Keep all the API security scopes.
#
# The API security scope consists of scope name, list of permitted and mandatory signers.
# The scope name is associated with API actions. For example, write_labels is associated with
# ability to create private labels, edit and remove them. The scopes which have «write» in the name are supposed
# to be dangerous so they must require more signatures then read-only scopes
#
# Each scope must include list of permitted and mandatory signers.
# Barong validates JWT signatures against permitted keys and doesn't trust
# JWTs which don't include signatures from all mandatory signers.
#
# Example:
#
# scopes:
# write_labels:
# permitted_signers: ['backend-1.mycompany.example', 'backend-2.mycompany.example']
# mandatory_signers: ['backend-1.mycompany.example', 'backend-2.mycompany.example']
#
# The available scopes include:
# write_labels
# - otp_sign
#
scopes: {}

View File

@@ -0,0 +1,22 @@
# Be sure to run "bin/install_plugins" when you modify this file.
#
# This file is used for listing Barong plugins.
# The plugins must be listed as an array. Each element of array described the plugin using the next variables:
#
# * name
# Mandatory. Specify plugin name. The name must be compatible with filesystem rules.
#
# * git
# Mandatory. Specify Git repository URL.
#
# * commit
# Mandatory. Specify commit hash which Barong will checkout via "bin/install_plugins".
#
# * require
# Optional. Specify relative path to file from vendor/plugins which should be required by Barong.
# You may set this value to "false" if you don't want Barong to require the plugin.
# Example configuration:
#- name: peatio-plugin-example
# git: https://github.com/rubykube/peatio-plugin-example.git
# commit: 11edd2e7c0bef229516f42fde79615a68a008d45