Skip to content

IsAuthenticated annotation #349

@BenSlabbert

Description

@BenSlabbert

currently we have github.benslabbert.vdw.codegen.annotation.auth.HasRole and github.benslabbert.vdw.codegen.annotation.auth.NoAuthCheck for routes

add a new annotation @IsAuthenticated

which simply checks that there is a user associated with the current request

    User user = ctx.user();
    if (null == user) {
        // not authenticated
        ctx.response().setStatusCode(401).end();
        return;
    }
    // rest of the code

handler code can then safely access the user and do whatever it wants to do with it

    @WebRequest.IsAuthenticated
    void all(@WebRequest.RoutingContext RoutingContext ctx) {
      User user = ctx.user();
      // safe to use user
      Authorizations authorizations = user.authorizations();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions