pluginserver 0.6.0__tar.gz → 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pluginserver
3
- Version: 0.6.0
3
+ Version: 0.6.3
4
4
  Summary: Plugin-driven API server
5
5
  Home-page: https://github.com/nicciniamh/pluginserver
6
6
  Author: Nicole Stevens
@@ -1,5 +1,6 @@
1
+ import asyncio
1
2
  from aiohttp import web
2
- import base64
3
+ import inspect
3
4
 
4
5
  class BasePlugin:
5
6
  """
@@ -12,7 +13,9 @@ class BasePlugin:
12
13
  self._apikey = None
13
14
  self.config = kwargs.get('config')
14
15
  self._plugin_id = kwargs.get('route_path',self.__class__.__name__.lower())
15
- auth = kwargs.get('auth_type').lower()
16
+ auth = kwargs.get('auth_type')
17
+ if auth:
18
+ auth = auth.lower()
16
19
  if auth:
17
20
  if auth == 'global':
18
21
  if 'auth' in self.config and 'apikey' in self.config.auth:
@@ -54,7 +57,7 @@ class BasePlugin:
54
57
  toktype='userdata'
55
58
  return token
56
59
  user_key = get_token(data) or get_custom_header_token(data) or get_user_token(data)
57
- print(f"_check_auth: type: {toktype} {self._auth_type} apikey {self._apikey}, args {data}")
60
+ #print(f"_check_auth: type: {toktype} {self._auth_type} apikey {self._apikey}, args {data}")
58
61
 
59
62
  if self._auth_type:
60
63
  #print(f"Checking {user_key}")
@@ -73,7 +76,9 @@ class BasePlugin:
73
76
  async def handle_request(self, **data):
74
77
  auth_check = self._check_auth(data)
75
78
  if auth_check:
76
- code, response = self.request_handler(**data)
79
+ result = self.request_handler(**data)
80
+ code, response = await result if inspect.isawaitable(result) else result
81
+ print(f"Got {code} - {response}")
77
82
  else:
78
83
  code, response = 403, {'error': 'unauthorized'}
79
84
  if not isinstance(response,web.Response):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pluginserver
3
- Version: 0.6.0
3
+ Version: 0.6.3
4
4
  Summary: Plugin-driven API server
5
5
  Home-page: https://github.com/nicciniamh/pluginserver
6
6
  Author: Nicole Stevens
@@ -4,7 +4,7 @@ from setuptools import setup
4
4
 
5
5
  setup(
6
6
  name='pluginserver',
7
- version='0.6.0',
7
+ version='0.6.3',
8
8
  packages=['plugincore'],
9
9
  include_package_data=True,
10
10
  description='Plugin-driven API server',
File without changes
File without changes
File without changes
File without changes