I did follow the below and got my application working. https://developer.okta.com/docs/guides/implement-grant-type/authcode/main/#grant-type-flow
But I couldnt get the session once the user is authenticated. I am using ServletFilter to navigate to okta login page(via /authorize endpoint), but i am not getting session in doFilter method.
I am using Primefaces for my UI.
Here is my sample code. In ServletFilter class... it comes here, but return session always empty.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
HttpSession httpSession = httpServletRequest.getSession(false); // return null here
This is the code in doFilter where I navigate to okta login page.
httpServletResponse.sendRedirect("https://XXX.oktapreview.com/oauth2/default/v1/authorize?client_id=0oa1w21hrnFPT01d7&response_type=code&response_mode=query&scope=openid email profile groups&state=xyz&redirect_uri=http://<host>:<port>/app");
CodePudding user response:
As Scary Wombat mentioned in the comment, it works with the new session that created. Thank you.