services/src/main/java/org/keycloak/services/resources/LoginActionsService.java
/**
     * URL called after login page.  YOU SHOULD NEVER INVOKE THIS DIRECTLY!
     *
     * @param code
     * @return
     */
URL called after login page.  YOU SHOULD NEVER INVOKE THIS DIRECTLY.
@param code
@return
URL called after login page . YOU SHOULD NEVER INVOKE THIS DIRECTLY . @param code @return
@Path("auth-form")
    @POST
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Response authForm(@QueryParam("code") String code) {
        event.event(EventType.LOGIN);
        if (!checkSsl()) {
            event.error(Errors.SSL_REQUIRED);
            return ErrorPage.error(session, Messages.HTTPS_REQUIRED);
        }
        if (!realm.isEnabled()) {
            event.error(Errors.REALM_DISABLED);
            return ErrorPage.error(session, Messages.REALM_NOT_ENABLED);
        }
        ClientSessionCode clientCode = ClientSessionCode.parse(code, session, realm);
        if (clientCode == null) {
            event.error(Errors.INVALID_CODE);
            return ErrorPage.error(session, Messages.INVALID_CODE);
        }
        ClientSessionModel clientSession = clientCode.getClientSession();
        event.detail(Details.CODE_ID, clientSession.getId());
        if (!clientCode.isValid(ClientSessionModel.Action.AUTHENTICATE) || clientSession.getUserSession() != null) {
            clientCode.setAction(ClientSessionModel.Action.AUTHENTICATE);
            event.client(clientSession.getClient()).error(Errors.EXPIRED_CODE);
            return session.getProvider(LoginFormsProvider.class)
                    .setError(Messages.EXPIRED_CODE)
                    .setClientSessionCode(clientCode.getCode())
                    .createLogin();
        }
        ClientModel client = clientSession.getClient();
        if (client == null) {
            event.error(Errors.CLIENT_NOT_FOUND);
            return ErrorPage.error(session, Messages.UNKNOWN_LOGIN_REQUESTER);
        }
        if (!client.isEnabled()) {
            event.error(Errors.CLIENT_DISABLED);
            return ErrorPage.error(session, Messages.LOGIN_REQUESTER_NOT_ENABLED);
        }
        String flowId = null;
        for (AuthenticationFlowModel flow : realm.getAuthenticationFlows()) {
            if (flow.getAlias().equals("browser")) {
                flowId = flow.getId();
                break;
            }
        }
        AuthenticationProcessor processor = new AuthenticationProcessor();
        processor.setClientSession(clientSession)
                .setFlowId(flowId)
                .setConnection(clientConnection)
                .setEventBuilder(event)
                .setProtector(authManager.getProtector())
                .setRealm(realm)
                .setSession(session)
                .setUriInfo(uriInfo)
                .setRequest(request);
        try {
            return processor.authenticate();
        } catch (AuthenticationProcessor.AuthException e) {
            return handleError(e, code);
        } catch (Exception e) {
            logger.error("failed authentication", e);
            return ErrorPage.error(session, Messages.UNEXPECTED_ERROR_HANDLING_RESPONSE);
        }
    }
@ Path ( "auth-form" ) @ POST @ Consumes ( MediaType . APPLICATION_FORM_URLENCODED ) public Response authForm ( @ QueryParam ( "code" ) String code ) { event . event ( EventType . LOGIN ) ; if ( ! checkSsl ( ) ) { event . error ( Errors . SSL_REQUIRED ) ; return ErrorPage . error ( session , Messages . HTTPS_REQUIRED ) ; } if ( ! realm . isEnabled ( ) ) { event . error ( Errors . REALM_DISABLED ) ; return ErrorPage . error ( session , Messages . REALM_NOT_ENABLED ) ; } ClientSessionCode clientCode = ClientSessionCode . parse ( code , session , realm ) ; if ( clientCode == null ) { event . error ( Errors . INVALID_CODE ) ; return ErrorPage . error ( session , Messages . INVALID_CODE ) ; } ClientSessionModel clientSession = clientCode . getClientSession ( ) ; event . detail ( Details . CODE_ID , clientSession . getId ( ) ) ; if ( ! clientCode . isValid ( ClientSessionModel . Action . AUTHENTICATE ) || clientSession . getUserSession ( ) != null ) { clientCode . setAction ( ClientSessionModel . Action . AUTHENTICATE ) ; event . client ( clientSession . getClient ( ) ) . error ( Errors . EXPIRED_CODE ) ; return session . getProvider ( LoginFormsProvider . class ) . setError ( Messages . EXPIRED_CODE ) . setClientSessionCode ( clientCode . getCode ( ) ) . createLogin ( ) ; } ClientModel client = clientSession . getClient ( ) ; if ( client == null ) { event . error ( Errors . CLIENT_NOT_FOUND ) ; return ErrorPage . error ( session , Messages . UNKNOWN_LOGIN_REQUESTER ) ; } if ( ! client . isEnabled ( ) ) { event . error ( Errors . CLIENT_DISABLED ) ; return ErrorPage . error ( session , Messages . LOGIN_REQUESTER_NOT_ENABLED ) ; } String flowId = null ; for ( AuthenticationFlowModel flow : realm . getAuthenticationFlows ( ) ) { if ( flow . getAlias ( ) . equals ( "browser" ) ) { flowId = flow . getId ( ) ; break ; } } AuthenticationProcessor processor = new AuthenticationProcessor ( ) ; processor . setClientSession ( clientSession ) . setFlowId ( flowId ) . setConnection ( clientConnection ) . setEventBuilder ( event ) . setProtector ( authManager . getProtector ( ) ) . setRealm ( realm ) . setSession ( session ) . setUriInfo ( uriInfo ) . setRequest ( request ) ; try { return processor . authenticate ( ) ; } catch ( AuthenticationProcessor . AuthException e ) { return handleError ( e , code ) ; } catch ( Exception e ) { logger . error ( "failed authentication" , e ) ; return ErrorPage . error ( session , Messages . UNEXPECTED_ERROR_HANDLING_RESPONSE ) ; } }
URL called after login page.
URL called after login page .