Announcement Announcement Module
Collapse
No announcement yet.
Redirect after authentication with some parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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).

    Comment

    Working...
    X