Results 1 to 2 of 2

Thread: Redirect after authentication with some parameters

  1. #1
    Join Date
    Sep 2011
    Posts
    11

    Default Redirect after authentication with some parameters

    Hi,
    I'm making my own application that will also cooperate with other application writen in PHP.
    But I'm stuck at the moment. I made my own AuthenticationHandler:
    Code:
    @Override
        public void onAuthenticationSuccess(HttpServletRequest httpServletRequest,
                                            HttpServletResponse httpServletResponse,
                                            Authentication authentication) throws IOException, ServletException
        {
            AnagUser user = (AnagUser) authentication.getPrincipal();
            String username = user.getUsername();
    
            Collection<GrantedAuthority> grantedAuthorities = authentication.getAuthorities();
    
            // redirect according to granted authorities
            if (grantedAuthorities.contains(new GrantedAuthorityImpl("ROLE_ADMIN"))) {
                httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "index");
            } else if (grantedAuthorities.contains(new GrantedAuthorityImpl("ROLE_USER"))) {
                httpServletResponse.sendRedirect("www.phpapp.com");
            } else if (grantedAuthorities.contains(new GrantedAuthorityImpl("ROLE_USER_OTHER"))) {
                httpServletResponse.sendRedirect("www.phpapp.com");
            }
    
            super.onAuthenticationSuccess(httpServletRequest, httpServletResponse,
                    authentication);
        }
    Code is working fine but the problem is I have no idea how to sent parameters to the other php app. I don't want to use GET as it will be visible for anyone. I don't know if I can use POST or SESSION in here.
    Basically in php app I want to catch those parameters and use them for authentication in other app.

    It's done like this because:
    - admin panel is in java app,
    - user panel (specific user panel) in in php app.

    Maybe I should use other approach but I don't really have access to php app.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    The easiest solution I can think of would be to include a Secure Random ID in the URL that points to data in a data store that can be shared between the Java and PHP application (i.e. a database).
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •