hi, i did something like this for one of my past projects.

Specifically what i did was to create my own
AuthenticationProcessingFilter that overrides getDefaultTargetUrl()

The methods looks like this:

@override
public String getDefaultTargetUrl() {
                String url = this.afterLoginRedirectService.getDefaultUrl();
                if (StringUtils.isBlank(url)){
                        url = super.getDefaultTargetUrl();
                }
                return url;
        }

afterLoginRedirectService is a tapestry service that obtains the url
to redirect after the authentication process is done. It has a
configuration map with the Role and the target url;

And then you need to override the authenticationProcessingFilter
provieded by  tapestry-spring-security

public static AuthenticationProcessingFilter
buildYourAuthenticationProcessingFilter(Map<Long, String>
configuration, Logger logger,
                        @SpringSecurityServices final AuthenticationManager 
manager,
@SpringSecurityServices final RememberMeServices rememberMeServices,
                        @Inject @Symbol("spring-security.check.url") final 
String authUrl,
@Inject @Symbol("spring-security.target.url") final String targetUrl,
                        @Inject @Symbol("spring-security.failure.url") final 
String
failureUrl, @InjectService("SuccessLoginChain") LoginActionCommand
successLoginChain,
                        @InjectService("FailedLoginChain") LoginActionCommand
failedLoginChain) throws Exception {

                AuthenticationProcessingFilter filter = new
YourAuthenticationProcessingFilter(successLoginChain,
failedLoginChain,
                                new 
AfterLoginRedirectServiceImpl(configuration), logger);

                filter.setAuthenticationManager(manager);
                filter.setAuthenticationFailureUrl(failureUrl);
                filter.setDefaultTargetUrl(targetUrl);
                filter.setFilterProcessesUrl(authUrl);
                filter.setRememberMeServices(rememberMeServices);
                filter.afterPropertiesSet();
                return filter;
        }

public static void
contributeAliasOverrides(Configuration<AliasContribution<?>>
configuration,
                        @InjectService("YourAuthenticationProcessingFilter")
AuthenticationProcessingFilter yourAuthenticationProcessingFilter) {

                //rewrite the authentication processing filter
                
configuration.add(AliasContribution.create(AuthenticationProcessingFilter.class,
yourAuthenticationProcessingFilter));

        }

And to configure the target urls in any module u can contribute to
your Filter :
public static void
contributeYourAuthenticationProcessingFilter(MappedConfiguration<Long,
String> configuration,
                        @Inject 
@Symbol(NebulaConstants.Symbols.DEFAULT_ADVISOR_URL) String
defaultAdvisorUrl) {

                configuration.add(SecurityConstants.Defaults.ADVISOR_ROLE_ID,
defaultAdvisorUrl);
        }

I hope it helps

On Fri, Dec 4, 2009 at 12:06 PM, TNO <tno...@free.fr> wrote:
> Hi,
>
> is it possible to have different target urls for different user roles.
>
> The ROLE_ADMIN goes to /admin, the ROLE_TOTO goes /page/toto, the
> ROLE_TITI goes to /page/titi, ...
>
>
> thanks
>
>
> ---
> Antivirus avast! : message Sortant sain.
> Base de donnees virale (VPS) : 091203-1, 03/12/2009
> Analyse le : 04/12/2009 12:06:56
> avast! - copyright (c) 1988-2009 ALWIL Software.
> http://www.avast.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to