Skip to content

Commit

Permalink
Merge pull request #29 from akakjs/esisecurity-datasource-fix
Browse files Browse the repository at this point in the history
Resolved an issue when using the test SSO server
  • Loading branch information
Kyria authored Feb 18, 2018
2 parents fac2bcf + 48f3cf2 commit 21bcb52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion esipy/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ def __init__(
:param app: (optionnal) the pyswagger app object
:param security_name: (optionnal) the name of the object holding the
informations in the securityDefinitions, used to check authed endpoint
:param esi_datasource: (optional) The ESI datasource used to validate
SSO authentication. Defaults to tranquility
"""
app = kwargs.pop('app', None)
sso_url = kwargs.pop('sso_url', "https://login.eveonline.com")
esi_url = kwargs.pop('esi_url', "https://esi.tech.ccp.is")
esi_datasource = kwargs.pop('esi_datasource', "tranquility")

self.security_name = kwargs.pop('security_name', 'evesso')
self.redirect_uri = redirect_uri
Expand Down Expand Up @@ -86,7 +89,10 @@ def __init__(
# use ESI url for verify, since it's better for caching
if esi_url is None or esi_url == "":
raise AttributeError("esi_url cannot be None or empty")
self.oauth_verify = '%s/verify/' % esi_url
self.oauth_verify = '%s/verify/?datasource=%s' % (
esi_url,
esi_datasource
)

# session request stuff
self._session = Session()
Expand Down
7 changes: 4 additions & 3 deletions test/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class TestEsiSecurity(unittest.TestCase):
CALLBACK_URI = "https://foo.bar/baz/callback"
LOGIN_EVE = "https://login.eveonline.com"
OAUTH_VERIFY = "https://esi.tech.ccp.is/verify/"
OAUTH_VERIFY = "https://esi.tech.ccp.is/verify/?datasource=tranquility"
OAUTH_TOKEN = "%s/oauth/token" % LOGIN_EVE
OAUTH_AUTHORIZE = "%s/oauth/authorize" % LOGIN_EVE
CLIENT_ID = 'foo'
Expand Down Expand Up @@ -114,12 +114,13 @@ def test_esisecurity_other_init(self):
client_id=TestEsiSecurity.CLIENT_ID,
secret_key=TestEsiSecurity.SECRET_KEY,
sso_url='foo.com',
esi_url='bar.baz'
esi_url='bar.baz',
esi_datasource='singularity'
)

self.assertEqual(
security.oauth_verify,
"bar.baz/verify/"
"bar.baz/verify/?datasource=singularity"
)
self.assertEqual(
security.oauth_token,
Expand Down

0 comments on commit 21bcb52

Please sign in to comment.