Skip to content

Commit 7c4bd43

Browse files
committed
Simplified auth
1 parent 13b84c0 commit 7c4bd43

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

wordpress/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import logging
1111
from json import dumps as jsonencode
1212

13-
from wordpress.auth import BasicAuth, OAuth, OAuth_3Leg, JWTAuth
13+
from wordpress.auth import BasicAuth, OAuth, OAuth_3Leg, NoAuth
1414
from wordpress.helpers import StrUtils, UrlUtils
1515
from wordpress.transport import API_Requests_Wrapper
1616

@@ -34,8 +34,8 @@ def __init__(self, url, consumer_key, consumer_secret, **kwargs):
3434
auth_class = BasicAuth
3535
elif kwargs.get('oauth1a_3leg'):
3636
auth_class = OAuth_3Leg
37-
elif kwargs.get('jwt_auth'):
38-
auth_class = JWTAuth
37+
elif kwargs.get('no_auth'):
38+
auth_class = NoAuth
3939

4040
if kwargs.get('version', '').startswith('wc') and kwargs.get('oauth1a_3leg'):
4141
self.logger.warn("WooCommerce JSON Api does not seem to support 3leg")

wordpress/auth.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,14 @@ def get_auth(self):
9494
return HTTPBasicAuth(self.consumer_key, self.consumer_secret)
9595

9696

97-
class JWTAuth(Auth):
97+
class NoAuth(Auth):
9898
"""
99-
Just injects an already generated and signed JWT token header
100-
in the request headers.
101-
It is up to the user to make sure this is sent via SSL.
99+
Just a dummy Auth object to allow header based
100+
authorization per request
102101
"""
103-
def __init__(self, requester, consumer_key, consumer_secret, **kwargs):
104-
super(JWTAuth, self).__init__(requester, **kwargs)
105-
self.consumer_key = consumer_key
106-
self.consumer_secret = consumer_secret
107-
self.jwt_token = kwargs.pop('jwt_token', None)
108-
self.jwt_header_format = kwargs.pop('jwt_header_format',
109-
u'JWT token="%s"')
110-
111102
def get_auth_url(self, endpoint_url, method, **kwargs):
112103
return endpoint_url
113104

114-
def __call__(self, request):
115-
"""
116-
Adds an `Authorization` header to the request.
117-
"""
118-
request.headers['Authorization'] = self._header_format % self.jwt_token
119-
return request
120-
121105

122106
class OAuth(Auth):
123107
""" Signs string with oauth consumer_key and consumer_secret """

0 commit comments

Comments
 (0)