Custom JAX-RS authorization - using JWT in each request

后端 未结 2 1631
天命终不由人
天命终不由人 2020-12-02 12:31

I have a JAX-RS service where I want all my users to access my services, but just those who have rights to see the result. Roles based security and existing REALMS and atuhe

2条回答
  •  执念已碎
    2020-12-02 13:29

    I was searching for an solution which is Jersey independent and works for Wildfly -> found this github example implementation:

    https://github.com/sixturtle/examples/tree/master/jaxrs-jwt-filter

    It should give you a hint how to solve it clean.

    Implement a JWTRequestFilter which implements ContainerRequestFilter https://github.com/sixturtle/examples/blob/master/jaxrs-jwt-filter/src/main/java/com/sixturtle/jwt/JWTRequestFilter.java

    as stated above and register the filter as resteasy provider in web.xml:

    
           Custom JAX-RS Providers
           resteasy.providers
           com.sixturtle.jwt.JWTRequestFilter
    
    
            resteasy.role.based.security
            true
    
    

提交回复
热议问题