Coder Social home page Coder Social logo

ratpack-pac4j's Introduction

This org.pac4j:ratpack-pac4j library is a mirror of the official Ratpack / pac4j module (io.ratpack:ratpack-pac4j) with newer versions of pac4j (as the Ratpack 1.x stream is stuck to pac4j v1.8.x).

Pac4j Ratpack New org.pac4j:ratpack-pac4j Changes Official io.ratpack:ratpack-pac4j
v1.8.x v1.4.6 v1.4.6 No changes: both modules are identical v1.4.6
v2.x (v2.1.0) v1.5.0 v2.0.0 The method signatures have changed: CommonProfile replaces UserProfile and HttpAction replaces RequiresHttpAction it doesn't exist
v3.x (v3.3.0) v1.5.0 v3.0.0 Created a RatpackSessionStore and manually retrieved the client_name. it doesn't exist
v5.x v1.9.0 v4.x it doesn't exist
v6.x v1.9.0 v5.x it doesn't exist

See the official documentation and the demo.

ratpack-pac4j's People

Contributors

leleuj avatar rnett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

leleuj rnett

ratpack-pac4j's Issues

`RatpackPac4j#requireAuth` should add `WWW-Authenticate` header on a 401

I'm testing an app using the following versions in my gradle config:

    compile group: 'io.ratpack', name: 'ratpack-groovy', version: '1.5.4'
    compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
//    compile ratpack.dependency('pac4j') // Don't use this, because we need the org.pac4j version
    compile group: 'org.pac4j', name: 'ratpack-pac4j', version: '2.0.0'
    compile group: 'org.pac4j', name: 'pac4j-core', version: '2.2.1'
    compile group: 'org.pac4j', name: 'pac4j-jwt', version: '2.2.1'
    compile group: 'org.pac4j', name: 'pac4j-http', version: '2.2.1'

I find that when I use this handler:

all RatpackPac4j.requireAuth(HeaderClient)

Unauthorized requests get rejected correctly with a 401 status, but I believe a WWW-Authenticate: ... header should be added, and it is not.

Checking the source code leads me to suspect RatpackPac4j#login, which sets the 401 code, but does not add this header:

  public static <C extends Credentials, U extends CommonProfile> Promise<U> login(Context ctx, Class<? extends Client> clientType) {
    if (isDirect(clientType)) {
      return userProfile(ctx)
        .flatMap(p -> {
          if (p.isPresent()) {
            Optional<U> cast = Types.cast(p);
            return Promise.value(cast);
          } else {
            return performDirectAuthentication(ctx, clientType);
          }
        })
        .route(p -> !p.isPresent(), p -> ctx.clientError(401))
        .map(Optional::get);
    } else {
      return userProfile(ctx)
        .route(p -> !p.isPresent(), p -> initiateAuthentication(ctx, clientType))
        .map(Optional::get)
        .map(Types::<U>cast);
    }

Thanks!

Pac4j stateless authentication

Ratpack-pac4j integration strictly bounds to HTTP session. This is not eligible for implementing stateless RESTful API.

Referring to pac4j documentation we should cache UserProfile using LocalCachingAuthenticator and use this approach as default behavior for all "direct clients".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.