@@ -404,15 +404,16 @@ private void authorizer(final Object authorizer, final String name, final String
404404 public Auth form (final String pattern ,
405405 final Class <? extends Authenticator <UsernamePasswordCredentials >> authenticator ) {
406406 bindings .put (pattern , (binder , conf ) -> {
407- TypeLiteral <Authenticator <UsernamePasswordCredentials >> usernamePasswordAuthenticator = new TypeLiteral <Authenticator <UsernamePasswordCredentials >>() {};
407+ TypeLiteral <Authenticator <UsernamePasswordCredentials >> usernamePasswordAuthenticator = new TypeLiteral <Authenticator <UsernamePasswordCredentials >>() {
408+ };
408409 binder .bind (usernamePasswordAuthenticator .getRawType ()).to (authenticator );
409410
410411 bindProfile (binder , CommonProfile .class );
411412
412413 Multibinder .newSetBinder (binder , Client .class )
413414 .addBinding ().toProvider (FormAuth .class );
414415
415- return new FormFilter (conf .getString ("auth.form.loginUrl" ), conf . getString ( "auth.callback" ));
416+ return new FormFilter (conf .getString ("auth.form.loginUrl" ), authCallbackPath ( conf ));
416417 });
417418
418419 return this ;
@@ -449,7 +450,8 @@ public Auth form() {
449450 public Auth basic (final String pattern ,
450451 final Class <? extends Authenticator <UsernamePasswordCredentials >> authenticator ) {
451452 bindings .put (pattern , (binder , config ) -> {
452- TypeLiteral <Authenticator <UsernamePasswordCredentials >> usernamePasswordAuthenticator = new TypeLiteral <Authenticator <UsernamePasswordCredentials >>() {};
453+ TypeLiteral <Authenticator <UsernamePasswordCredentials >> usernamePasswordAuthenticator = new TypeLiteral <Authenticator <UsernamePasswordCredentials >>() {
454+ };
453455 binder .bind (usernamePasswordAuthenticator .getRawType ()).to (authenticator );
454456
455457 bindProfile (binder , CommonProfile .class );
@@ -635,7 +637,7 @@ public Auth logout(final String logoutUrl) {
635637
636638 @ SuppressWarnings ({"rawtypes" , "unchecked" })
637639 @ Override
638- public void configure (final Env env , final Config config , final Binder binder ) {
640+ public void configure (final Env env , final Config conf , final Binder binder ) {
639641 binder .bind (Clients .class ).toProvider (ClientsProvider .class );
640642
641643 binder .bind (org .pac4j .core .config .Config .class ).toProvider (ConfigProvider .class );
@@ -646,21 +648,18 @@ public void configure(final Env env, final Config config, final Binder binder) {
646648 OptionalBinder .newOptionalBinder (binder , ClientFinder .class )
647649 .setDefault ().toInstance (new DefaultClientFinder ());
648650
649- String fullcallback = config .getString ("auth.callback" );
650- String callback = URI .create (fullcallback ).getPath ();
651-
652651 Router routes = env .router ();
653652
654653 MapBinder <String , Authorizer > authorizers = MapBinder
655654 .newMapBinder (binder , String .class , Authorizer .class );
656655
657- routes .use ("*" , callback , (req , rsp , chain ) -> req
656+ routes .use ("*" , authCallbackPath ( conf ) , (req , rsp , chain ) -> req
658657 .require (AuthCallback .class ).handle (req , rsp , chain ))
659658 .excludes ("/favicon.ico" )
660659 .name ("auth(Callback)" );
661660
662- routes .use ("*" , logoutUrl .orElse (config .getString ("auth.logout.url" )),
663- new AuthLogout (redirecTo .orElse (config .getString ("auth.logout.redirectTo" ))))
661+ routes .use ("*" , logoutUrl .orElse (conf .getString ("auth.logout.url" )),
662+ new AuthLogout (redirecTo .orElse (conf .getString ("auth.logout.redirectTo" ))))
664663 .name ("auth(Logout)" );
665664
666665 if (bindings .size () == 0 ) {
@@ -672,7 +671,7 @@ public void configure(final Env env, final Config config, final Binder binder) {
672671 String pattern = e .getKey ();
673672 List <AuthFilter > filters = new ArrayList <>();
674673 e .getValue ().forEach (it -> {
675- AuthFilter filter = it .apply (binder , config );
674+ AuthFilter filter = it .apply (binder , conf );
676675 if (filters .size () == 0 ) {
677676 // push 1st filter
678677 filters .add (filter );
@@ -713,6 +712,13 @@ public void configure(final Env env, final Config config, final Binder binder) {
713712 });
714713 }
715714
715+ private String authCallbackPath (final Config conf ) {
716+ String fullcallback = conf .getString ("auth.callback" );
717+ String root = conf .getString ("application.path" );
718+ String callback = URI .create (fullcallback ).getPath ().replace (root , "" );
719+ return Route .normalize (callback );
720+ }
721+
716722 @ Override
717723 public Config config () {
718724 return ConfigFactory .parseResources (getClass (), "auth.conf" );
0 commit comments