Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.py] | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
__version__ = '0.0.1b' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import logging | ||
|
||
from aiohttp.web import HTTPForbidden | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def check_scopes(scopes=list()): | ||
def factory(func): | ||
async def wrapped(self, request): | ||
if not request.get('user'): | ||
return HTTPForbidden( | ||
content_type='application/json', | ||
body=json.dumps({ | ||
'error': 'Insufficient scopes' | ||
}) | ||
) | ||
|
||
return await func(self, request) | ||
return wrapped | ||
|
||
return factory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import aiohttp | ||
import asyncio | ||
|
||
def jwt_middleware(secret=None, token_getter=None, options=dict()): | ||
if not ( secret and type(secret) is str ): | ||
raise Exception('\'secret\' should be provided') | ||
|
||
async def factory(app, handler): | ||
async def middleware(request): | ||
pass | ||
return middleware | ||
|
||
return factory |