How to use the guardpost.authentication.User 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_controllers.py View on Github external
async def on_request(self, request: Request):
            request.identity = User({'id': '001', 'name': 'Charlie Brown'}, 'JWTBearer')
github RobertoPrevato / BlackSheep / tests / test_normalization.py View on Github external
    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_controllers.py View on Github external
async def index(self, request: Request, user: Optional[User]):
            assert hasattr(request, 'identity')
            assert isinstance(request.identity, User)
            return text(request.identity.name)
github RobertoPrevato / BlackSheep / blacksheep / server / normalization.py View on Github external
if name in services:
        return FromServices(name, services)

    # 2B. do services contain a service with matching type?
    if annotation in services:
        return FromServices(annotation, services)

    # 3. does route contain a parameter with matching name?
    if route and name in route.param_names:
        return FromRoute(annotation, name)

    # 4. is simple type?
    if annotation in _simple_types_handled_with_query:
        return FromQuery(annotation, name, required=not is_optional)

    if annotation is User or annotation is Identity:
        return IdentityBinder()

    # 5. from json body (last default)
    return FromJson(annotation, required=not is_optional)