Navigation Menu

Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
hzlmn committed Sep 12, 2017
1 parent 6776dc8 commit f22b3bf
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
@@ -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 added .gitattributes
Empty file.
Empty file added .gitignore
Empty file.
Empty file added CHANGELOG.md
Empty file.
Empty file added LICENSE
Empty file.
2 changes: 2 additions & 0 deletions aiohttp_jwt/__init__.py
@@ -0,0 +1,2 @@

__version__ = '0.0.1b'
23 changes: 23 additions & 0 deletions aiohttp_jwt/decorators.py
@@ -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
13 changes: 13 additions & 0 deletions aiohttp_jwt/middleware.py
@@ -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
Empty file added setup.py
Empty file.

0 comments on commit f22b3bf

Please sign in to comment.