How to use the guardpost.authentication.Identity function in guardpost

To help you get started, we’ve selected a few guardpost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RobertoPrevato / BlackSheep / tests / test_normalization.py View on Github external
    Identity,
    User,
    Optional[User],
    Optional[Identity]
])
def test_identity_binder_by_param_type(annotation_type):
    async def handler(param):
        ...

    handler.__annotations__['param'] = annotation_type

    binders = get_binders(Route(b'/', handler), {})

    assert isinstance(binders[0], IdentityBinder)
github RobertoPrevato / BlackSheep / tests / test_auth.py View on Github external
def __init__(self, identity=None):
        if identity is None:
            identity = Identity({
                'id': '001',
                'name': 'Charlie Brown'
            }, 'JWT')
        self.identity = identity
github RobertoPrevato / BlackSheep / tests / test_auth.py View on Github external
async def test_authorization_policy_success():
    app = FakeApplication()

    admin = Identity({
        'id': '001',
        'name': 'Charlie Brown',
        'role': 'admin'
    }, 'JWT')

    app.use_authentication()\
        .add(MockAuthHandler(admin))

    app.use_authorization()\
        .add(AdminsPolicy())

    @auth('admin')
    @app.router.get(b'/')
    async def home():
        return None
github RobertoPrevato / BlackSheep / tests / test_auth.py View on Github external
async def authenticate(self, context: Any) -> Optional[Identity]:
        context.identity = Identity({
            'id': '007',
        })  # NB: an identity without authentication scheme is treated as anonymous identity
        return context.identity
github RobertoPrevato / BlackSheep / tests / test_auth.py View on Github external
    async def authenticate(self, context: Any) -> Optional[Identity]:
        context.identity = Identity({
            'id': '007',
        })  # NB: an identity without authentication scheme is treated as anonymous identity
        return context.identity
github RobertoPrevato / BlackSheep / blacksheep / server / bindings.py View on Github external
def __init__(self):
        super().__init__('identity', Identity)