Skip to content

Commit

Permalink
Merge pull request #297 from consideRatio/fix-mediawiki-with-0.3.7-mw…
Browse files Browse the repository at this point in the history
…oauth

mediawiki: utf-8 > binary strings, req. mwoauth>=0.3.7
  • Loading branch information
consideRatio authored Oct 30, 2019
2 parents dbf390d + cb70e46 commit d2a8d11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions oauthenticator/mediawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
# It is a named tuple with bytestrings, json.dumps balks
def jsonify(request_token):
return json.dumps([
request_token.key.decode('utf-8'),
request_token.secret.decode('utf-8')
request_token.key,
request_token.secret,
])


def dejsonify(js):
key, secret = json.loads(js.decode('utf-8'))
return RequestToken(key.encode('utf-8'), secret.encode('utf-8'))
key, secret = json.loads(js)
return RequestToken(key, secret)


class MWLoginHandler(BaseHandler):
Expand Down Expand Up @@ -135,8 +135,8 @@ async def authenticate(self, handler, data=None):
return {
'name': identity['username'].replace(' ', '_'),
'auth_state': {
'ACCESS_TOKEN_KEY': access_token.key.decode('utf-8'),
'ACCESS_TOKEN_SECRET': access_token.secret.decode('utf-8'),
'ACCESS_TOKEN_KEY': access_token.key,
'ACCESS_TOKEN_SECRET': access_token.secret,
'MEDIAWIKI_USER_IDENTITY': identity,

}
Expand Down
2 changes: 1 addition & 1 deletion oauthenticator/tests/test_mediawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def test_mediawiki(mediawiki):
get_secure_cookie=Mock(
return_value=json.dumps(
['key', 'secret']
).encode('utf8')
)
),
request=Mock(
query='oauth_token=key&oauth_verifier=me'
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
codecov
flake8
pyjwt
mwoauth != 0.3.1, != 0.3.5
mwoauth >= 0.3.7
pytest >= 2.8
pytest-cov
pytest-asyncio
Expand Down

0 comments on commit d2a8d11

Please sign in to comment.