Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ PLACE_URI=https://example.place.technology
# Default Timezone
STAFF_TIME_ZONE=Australia/Sydney #default to UTC if not provided

SSL_VERIFY_NONE=true # Whether staff-api should verify the SSL cert that PlaceOS rest-api presents
# Host header to use when connecting to PlaceOS endpoints
PLACE_HOST_HEADER=example.place.technology

# Skip SSL verification when connecting to PlaceOS endpoints
SSL_VERIFY_NONE=true

# Sentry monitoring
SENTRY_DSN=<sentry dsn>
Expand Down
2 changes: 2 additions & 0 deletions src/constants.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module App

PLACE_URI = ENV["PLACE_URI"]?.presence || abort("PLACE_URI not in environment")

PLACE_HOST_HEADER = ENV["PLACE_HOST_HEADER"]?.presence

SSL_VERIFY_NONE = !!ENV["SSL_VERIFY_NONE"]?.presence.try { |var| var.downcase.in?("1", "true") }

PG_UNIQUE_CONSTRAINT_REGEX = /duplicate key value violates unique constraint/
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/utilities/placeos-helpers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require "promise"
module Utils::PlaceOSHelpers
# Base URL of the PlaceOS instance we are interacting with
PLACE_URI = App::PLACE_URI
PLACE_HOST_HEADER = App::PLACE_HOST_HEADER

@placeos_client : PlaceOS::Client? = nil

Expand All @@ -13,15 +14,15 @@ module Utils::PlaceOSHelpers
if key = request.headers["X-API-Key"]?
PlaceOS::Client.new(
PLACE_URI,
host_header: request.headers["Host"]?,
host_header: PLACE_HOST_HEADER || request.headers["Host"]?,
insecure: ::App::SSL_VERIFY_NONE,
x_api_key: key
)
else
PlaceOS::Client.new(
PLACE_URI,
token: OAuth2::AccessToken::Bearer.new(acquire_token.not_nil!, nil),
host_header: request.headers["Host"]?,
host_header: PLACE_HOST_HEADER || request.headers["Host"]?,
insecure: ::App::SSL_VERIFY_NONE
)
end
Expand Down
Loading