Commit 0a2e0eaf by source_reader

added azure deployment target and modified app url handling

parent 73f7685a
...@@ -10,16 +10,32 @@ class DataAppController < ApplicationController ...@@ -10,16 +10,32 @@ class DataAppController < ApplicationController
InterfaceAuthToken.where(user: current_user, data_app: @app).destroy_all InterfaceAuthToken.where(user: current_user, data_app: @app).destroy_all
@auth_url = _app_auth_url @auth_url = _app_auth_url
if @auth_url.nil?
head :not_availble and return
end
end end
private private
def _app_auth_url def _app_auth_url
return "#" unless request.headers.key?("HTTP_X_APP_BASE_URI") # apps not enabled # apps require a proxy server (like nginx)
return nil unless (
request.headers.key?("HTTP_X_APP_BASE_URI") or
request.headers.key?("HTTP_X_APP_SERVER_NAME"))
# try to use the server name header, otherwise try the base_uri
token = InterfaceAuthToken.create(data_app: @app, token = InterfaceAuthToken.create(data_app: @app,
user: current_user, expiration: 5.minutes.from_now) user: current_user,
base = request.headers["HTTP_X_APP_BASE_URI"] expiration: 5.minutes.from_now)
"#{base}/#{token.data_app.id}/?auth_token=#{token.value}" # proxy supports subdomains (preferred because more secure and flexible)
if request.headers.key?("HTTP_X_APP_SERVER_NAME")
server = request.headers["HTTP_X_APP_SERVER_NAME"]
scheme = request.headers["HTTP_X_APP_SERVER_SCHEME"]
"#{scheme}://#{token.data_app.id}.app.#{server}?auth_token=#{token.value}"
# fall back on hosting apps relative to the base url
else
base = request.headers["HTTP_X_APP_BASE_URI"]
"#{base}/#{token.data_app.id}/?auth_token=#{token.value}"
end
end end
end end
# config valid only for current version of Capistrano # config valid only for current version of Capistrano
lock "3.11.0" lock "3.11.1"
set :application, "lumen-api" set :application, "lumen-api"
set :repo_url, "git@git.wattsworth.net:wattsworth/control-api.git" set :repo_url, "git@git.wattsworth.net:wattsworth/control-api.git"
......
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
server "cloud2.wattsworth.net", user: "rails", roles: %w{app db web}, port: 22
# server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value
# server "db.example.com", user: "deploy", roles: %w{db}
set :deploy_to, "/opt/api"
set :bundle_without, [:development, :test, :local]
append :linked_files, "config/database.yml", "config/initializers/smtp.rb"
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
set :ssh_options, {
keys: %w(/Users/jdonnal/.ssh/id_rsa),
forward_agent: true,
auth_methods: %w(publickey)
}
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server "example.com",
# user: "user_name",
# roles: %w{web app},
# ssh_options: {
# user: "user_name", # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: "please use keys"
# }
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
# 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
# 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 = :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
# 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 = "control_panel_#{Rails.env}"
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = {:host => 'cloud.wattsworth.net'}
config.action_mailer.delivery_method = :smtp
# 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 = false
# 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 = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# ------- Lumen Custom Settings ----------
#
# display custom label in page header
#
config.node_name = "USNA Cloud"
# enable password recovery and e-mail invitations
# NOTE: configure smtp.rb with SMTP server details
#
config.send_emails = true
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment