Skip to content

Commit

Permalink
Added HOST_URL setting
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban committed Jan 31, 2020
1 parent 3f9ebe6 commit c7a8647
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ environment or included in ``PROJECT_ROOT/.env``.
STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
HORIZON_URI="https://horizon-testnet.stellar.org/"
SERVER_JWT_KEY="yoursupersecretjwtkey"
HOST_URL="https://example.com"

Polaris supports anchoring one or multiple assets on the Stellar network. ``ASSETS``
should be a comma-separated list of asset codes such as "USD", "ETH", or "MYCOIN".
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ environment or included in ``PROJECT_ROOT/.env``.
STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
HORIZON_URI="https://horizon-testnet.stellar.org/"
SERVER_JWT_KEY="yoursupersecretjwtkey"
HOST_URL="https://example.com"

Polaris supports anchoring one or multiple assets on the Stellar network. ``ASSETS``
should be a comma-separated list of asset codes such as "USD", "ETH", or "MYCOIN".
Expand Down
4 changes: 4 additions & 0 deletions polaris/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ SIGNING_SEED="SCY4F6VEIIPXPLTNQSFT5427H64YK3H3LB27H7WAOVDQSV2UACRWTPGM"
# "Public Global Stellar Network ; September 2015" or a custom passphrase
# if you're using a private network.
STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"

# HORIZON_URI can point to a custom Horizon URI. It currently points
# to the testnet URL.
HORIZON_URI="https://horizon-testnet.stellar.org/"

SERVER_JWT_KEY="secret"

HOST_URL="https://example.com"
3 changes: 2 additions & 1 deletion polaris/polaris/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module defines helpers for various endpoints."""
import os
import logging
import codecs
import time
Expand Down Expand Up @@ -109,7 +110,7 @@ def validate_jwt_request(request: Request) -> str:
except InvalidTokenError as e:
raise ValueError(str(e))

if jwt_dict["iss"] != request.build_absolute_uri("/auth"):
if jwt_dict["iss"] != os.path.join(settings.HOST_URL, "auth"):
raise ValueError("'jwt' has incorrect 'issuer'")
current_time = time.time()
if current_time < jwt_dict["iat"] or current_time > jwt_dict["exp"]:
Expand Down
3 changes: 2 additions & 1 deletion polaris/polaris/sep10auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md
"""
import os
import binascii
import json
import time
Expand Down Expand Up @@ -166,7 +167,7 @@ def _generate_jwt(request: Request, envelope_xdr: str) -> str:
)
hash_hex = binascii.hexlify(transaction_envelope.hash()).decode()
jwt_dict = {
"iss": request.build_absolute_uri("/auth"),
"iss": os.path.join(settings.HOST_URL, "auth"),
"sub": source_account,
"iat": issued_at,
"exp": issued_at + 24 * 60 * 60,
Expand Down
1 change: 1 addition & 0 deletions polaris/polaris/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@
OPERATION_DEPOSIT = "deposit"
OPERATION_WITHDRAWAL = "withdraw"
ACCOUNT_STARTING_BALANCE = str(2.01)
HOST_URL = env("HOST_URL")

0 comments on commit c7a8647

Please sign in to comment.