# .env
# Base-level System Environment Variables

# export env_file=$(echo '.env' >> debug_env_load_order.txt)

# Put system environment variables in this file which may be common
# across all environments - or which represent a documenting type.

# DO NOT set the values of RACK_ENV, RAILS_ENV and DEPLOY_TYPE in any .env* file.
# Set those values in your terminal/console window or invoking shell script.


############################################################
# Application specific things of most interest to the CM
# which may need to be over-riden in a .env.local file on
# a host deployment.

# This will retrieve the last tag set in the git repo for this
# git working directory.
export APP_VERSION=$(git describe --abbrev=0 --tags)

# APP_URL is the thing that is exposed to the outside world.
# The value shown here is for developer's workstations.  This
# will have to change in a .env.#{DEPLOY_TYPE} file for deployment to
# other hosts.

export APP_URL="http://localhost:4567"

# Used in the rake admin:add_users task; may be needed for other outgoing eMails.
# Will change based upon which host this code is running.

# FIXME: Why is this system environment variable different from APP_URL ??
#        This domain name is not part of the release architecture.  It should be
#        set in some .env.#{DEPLOY_TYPE} file not this one.
export APP_LOGIN_URL=$APP_URL/sign_in


############################################################
# Ruby/Rails related

export BUNDLE_GEMFILE='Gemfile'

# Rails log level.
#   Accepted values: debug, info, warn, error, fatal, or unknown
export LOG_LEVEL=debug


############################################################
# redis server related

export REDIS_HOST=localhost
export REDIS_PORT=PORT
export REDIS_DB_DEFAULT=0

export REDIS_URL=redis://$REDIS_HOST:$REDIS_PORT/$REDIS_DB_DEFAULT

# export REDIS_PASSWORD=REDACTED


############################################################
# sidekiq related

export SIDEKIQ_SERVER_HOST=localhost
export SIDEKIQ_CLIENT_HOST=localhost


############################################################
# Debug/Misc.

export DEVELOPER_TESTING=true
export ENABLE_OPENSSL_INITIALIZER=true


############################################################
# Application functionality switches

export DISPLAY_FACILITY_DROPDOWNS=false  # Determines whether Facility dropdowns appear

export ALWAYS_MINIFY_ASSETS=false        # Determines whether to auto-minify JS/CSS assets

############################################################
# Application/web-server related

export PUMA_WORKERS=0           # Number of workers in addition to the Master Process
export PUMA_WORKER_TIMEOUT=60   # seconds

export PUMA_MIN_THREADS=1       # threads per master/workerprocess
export PUMA_MAX_THREADS=4       # threads per master/worker process

# NOTE: if PUMA_BIND is defined, these three values will not be used by Puma >>>
export PUMA_HOST=0.0.0.0        # typical could be 127.0.0.1 if you wanted
export PUMA_PORT=PORT          # Puma convention calls for 9292; using unicorn's default instead
export PUMA_PROTOCOL='tcp://'   # tcp is usually the protocol unles bind is fully exploited


export PUMA_BIND="$PUMA_PROTOCOL$PUMA_HOST:$PUMA_PORT"   # takes precedence over its components

# NOTE: Used when the protocol is "ssl://"

# export PUMA_SSL_KEY_PATH=relative/path/from/rails_root/key.file
# export PUMA_SSL_CERT_PATH=relative/path/from/rails_root/cert.file

# export PUMA_BIND="$PUMA_PROTOCOL$PUMA_HOST:$PUMA_PORT/?key=$PUMA_SSL_KEY_PATH&cert=$PUMA_SSL_CERT_PATH"


export PUMA_REDIRECT_LOGS=true  # true: both STDOUT and STDERR are sent to files in the log directory
                                # false: both STDOUT and STDERR go to the console

export PUMA_DAEMONIZE=true      # true: puts puma into the background
                                # false: keeps puma in the foreground (required by docker deployment)

# The reason that PUMA_PORT is set to PORT is because that is the port that was opened
# for the CPP team to use on the QA/Test server provided by the CUI team for us to
# use.  CUI used passenger on port 3000; CPP used unicorn (now puma) on port 4567.


############################################################
# Configuration for eMail not related to feedback
# For example user notifications, password resets, etc.

# Action mailer (e-mail) settings.
# You will need to enable less secure apps in your Google account if you plan
# to use GMail as your e-mail SMTP server.
# You can do that here: https://www.google.com/settings/security/lesssecureapps

export EMAIL_SANITIZE=false
export EMAIL_HOST='smtp.gmail.com'
export EMAIL_PORT=PORT
export EMAIL_DOMAIN='gmail.com'
export EMAIL_USER='notification.cpptestuser@gmail.com'
export EMAIL_PASS='REDACTED'

# Sanitize Email

export SANITIZED_EMAIL='cui.testing@gmail.com'


##################################
# Feedback integration with Hipchat and Email notifications

export ENABLE_FEEDBACK=true


##################################
# Hipchat notification of feedback

# NOTE:  The IM gateway is used by both hipchat and slack notifications
# SMELL: The hostname may need to be changed to 127.0.0.1
export FEEDBACK_IM_GATEWAY='druby://localhost:9999'

export ENABLE_FEEDBACK_HIPCHAT=true

export FEEDBACK_HIPCHAT_SERVER=evss.hipchat.com
export FEEDBACK_HIPCHAT_ROOM='CPP Feedback'
export FEEDBACK_HIPCHAT_TOKEN='REDACTED'


##################################
# slack notification of feedback

# NOTE: Slack notifications are also sent via the FEEDBACK_IM_GATEWAY

# This is for teamcuiva.slack.com
export ENABLE_FEEDBACK_SLACK=true

# This incoming webhook URL is associated with the #feedback channel
export FEEDBACK_SLACK_WEBHOOK_URL='https://hooks.slack.com/services/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'

export FEEDBACK_SLACK_CHANNEL='#feedback'
export FEEDBACK_SLACK_USERNAME='feedbacker'


##################################
# eMail notification of feedback

export ENABLE_FEEDBACK_EMAIL=true

# multiple eMail addresses can be included as a comma separated list
export FEEDBACK_EMAIL_TO='CPPFeedback@DOMAIN'
export FEEDBACK_EMAIL_SUBJECT='CUI/CPP Feedback'

export FEEDBACK_EMAIL_SANITIZE=false
export FEEDBACK_EMAIL_HOST=$EMAIL_HOST
export FEEDBACK_EMAIL_PORT=$EMAIL_PORT
export FEEDBACK_EMAIL_DOMAIN=$EMAIL_DOMAIN
export FEEDBACK_EMAIL_USER=$EMAIL_USER
export FEEDBACK_EMAIL_PASS=$EMAIL_PASS


############################################################
# Database

# NOTE: Remove PostgreSQL "PG*" environment variables defined in your
#       terminal/console session.

export DBADAPTER='postgresql'
export DBHOST='localhost'
export DBPORT=PORT
export DBNAME='REDACTED'
export DBUSER='REDACTED'
export DBPASS='REDACTED'


############################################################
# Docker-related

# NOTE: DBRESET, DBMIGRATE abd DBSEED are used by the docker deployment process.
#       More specifically they are used by the rake prep:db task located at
#       lib/tasks/prep.rake

export DBRESET=false    # Invoke db:reset before app:start
export DBMIGRATE=false  # Invoke db:migrate before app:start
export DBSEED=false     # Does rake db:seed when true on docker container startup

# Used in the Rails.root/db_docker-compose.yml file.
# This is the port for the PostgreSQK server from the host's point of view
# In development it is usually the same as $DBPORT.  In production
# it can be anything.

export DOCKER_HOST_DB_PORT=$DBPORT

# Used in the Rails.root/redis_docker-compose.yml file.
# This is the port for the redis server from the host's point of view
# In development it is usually the same as $REDIS_PORT.  In production
# it can be anything.

export DOCKER_HOST_REDIS_PORT=$REDIS_PORT

# Used in the Rails.root/web_docker-compose.yml file.
# This is the port for the application server from the host's point of view
# In production this port is typically 80.  In development it is usually
# the same as $PUMA_PORT

export DOCKER_HOST_WEB_PORT=$PUMA_PORT


############################################################
# NPI Registry

# FIXME: change this to NPI_LOOKUP_URL
export URL_FOR_NPI_LOOKUP='https://npiregistry.cms.hhs.gov'


############################################################
# Veterans Exchange API web-service

export VX_API_BASE_URL=https://ehmp.vaftl.us/resource
export VX_API_AUTH_URL=$VX_API_BASE_URL/authentication

export VX_API_CREDENTIALS='{"accessCode": "REDACTED","verifyCode": "REDACTED","site": "9E7A"}'


############################################################
# VIA API web-service

export VIA_API_WSDL=''
export VIA_API_ENDPOINT_URL=http://localhost:7011/via-webservices/services/FindPatientService
export VIA_API_NAMESPACE=http://DNS        .URL       /

# Credentials used in VIA operations

export VIA_REQ_APP="VIA!Tester"
export VIA_CONS_APP_TOKEN="VIA#Tester_ID"
export VIA_CONS_APP_PASS="iU6rW8xj1g"


############################################################
# SAML-related support SSO via SSOi and id.me

# This is the base URL of the application; the port number is
# subject to changes based upon whether the application is running
# under docker or not.  The IPADDRESS is subject to which host
# the applicatoin is running under.  THe protocol while in development
# is http BUT when in production it will have to be HTTPS

export SAML_ISSUER=$APP_URL     # http://52.222.56.104:4567 if on the QA/Test server

# Relative to $APP_URL

export SAML_CALLBACK=saml/callback
export SAML_LOGOUT=saml/logout

# This is the URL provided by id.me

export SAML_METADATA_URL=https://api.idmelabs.com/saml/metadata/provider

# Filenames relative to Rails.root

export SAML_CERTIFICATE='tmp_certs/cpp-saml.crt'
export SAML_KEY='tmp_certs/cpp-saml.key'

# FIXME: these both reference port 3001 as if they might
#        be leftovers from the SSOi and passenger

# export SAML_RELAY=http://localhost:3001/auth/login/callback
# export SAML_LOGOUT_RELAY=http://localhost:3001/logout


############################################################
# Data storage integration

# FIXME: Why are these here without a value?

# export VLER_DAS_CACERT=''
# export VLER_DAS_CERT=''
# export VLER_DAS_CIPHER_SUITES=''
# export VLER_DAS_KEYFILE=''
# export VLER_DAS_KEYPASS=''
# export VLER_DAS_URL=''


############################################################
# Unknown stuff that requires documentation from the
# CUI feature set teams.

# FIXME: variable is too generic
export CALLBACK_URL='https://SERVER.DOMAIN/users/auth/saml/callback'

# FIXME: Why is this here without a value?
# export CUI_DISABLE_UNDER_REVIEW=''

export IDP_CERT_FINGERPRINT='A0:E8:07:73:D8:A1:CD:71:A2:16:6E:88:01:5F:99:9E:68:A9:28:90'
export IDP_TARGET_URL='https://SERVER.DOMAIN/fedredirectjsp/fedredirect.jsp?SPID=CUI'

export ISSUER='CUI'
export NAME_IDENTIFIER_FORMAT='urn:oasis:names:tc:SAML:2.0:nameid-format:email'

# FIXME: Why are these here without values?

# export ENABLE_PHASE_2=''
# export PHASE_2_BODY_SYSTEMS=''

# export SECRET_KEY_BASE=''
# export VBMS_UPLOADER_ENV=''
