keycloak-service
公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 限定公開変数類 | 関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.services.resources.LoginActionsService クラス
org.keycloak.services.resources.LoginActionsService 連携図
Collaboration graph

公開メンバ関数

 LoginActionsService (RealmModel realm, EventBuilder event)
 
Response restartSession (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response authenticate (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response authenticateForm (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response resetCredentialsPOST (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId, @QueryParam(Constants.KEY) String key)
 
Response resetCredentialsGET (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response executeActionToken (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(Constants.KEY) String key, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response registerPage (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response processRegister (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response firstBrokerLoginGet (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response firstBrokerLoginPost (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response postBrokerLoginGet (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response postBrokerLoginPost (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response processConsent (final MultivaluedMap< String, String > formData)
 
Response requiredActionPOST (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) final String code, @QueryParam(Constants.EXECUTION) String action, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 
Response requiredActionGET (@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) final String code, @QueryParam(Constants.EXECUTION) String action, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
 

静的公開メンバ関数

static UriBuilder loginActionsBaseUrl (UriInfo uriInfo)
 
static UriBuilder authenticationFormProcessor (UriInfo uriInfo)
 
static UriBuilder requiredActionProcessor (UriInfo uriInfo)
 
static UriBuilder actionTokenProcessor (UriInfo uriInfo)
 
static UriBuilder registrationFormProcessor (UriInfo uriInfo)
 
static UriBuilder firstBrokerLoginProcessor (UriInfo uriInfo)
 
static UriBuilder postBrokerLoginProcessor (UriInfo uriInfo)
 
static UriBuilder loginActionsBaseUrl (UriBuilder baseUriBuilder)
 
static Response redirectToAfterBrokerLoginEndpoint (KeycloakSession session, RealmModel realm, UriInfo uriInfo, AuthenticationSessionModel authSession, boolean firstBrokerLogin)
 

静的公開変数類

static final String AUTHENTICATE_PATH = "authenticate"
 
static final String REGISTRATION_PATH = "registration"
 
static final String RESET_CREDENTIALS_PATH = "reset-credentials"
 
static final String REQUIRED_ACTION = "required-action"
 
static final String FIRST_BROKER_LOGIN_PATH = "first-broker-login"
 
static final String POST_BROKER_LOGIN_PATH = "post-broker-login"
 
static final String RESTART_PATH = "restart"
 
static final String FORWARDED_ERROR_MESSAGE_NOTE = "forwardedErrorMessage"
 
static final String SESSION_CODE = "session_code"
 
static final String AUTH_SESSION_ID = "auth_session_id"
 

限定公開メンバ関数

URI getLastExecutionUrl (String flowPath, String executionId, String clientId, String tabId)
 
Response processAuthentication (boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
 
Response processFlow (boolean action, String execution, AuthenticationSessionModel authSession, String flowPath, AuthenticationFlowModel flow, String errorMessage, AuthenticationProcessor processor)
 
Response resetCredentials (String authSessionId, String code, String execution, String clientId, String tabId)
 
Response processResetCredentials (boolean actionRequest, String execution, AuthenticationSessionModel authSession, String errorMessage)
 
Response processRegistration (boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
 
Response brokerLoginFlow (String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
 

限定公開変数類

HttpHeaders headers
 
Providers providers
 
KeycloakSession session
 

関数

AuthenticationSessionModel createAuthenticationSessionForClient () throws UriBuilderException, IllegalArgumentException
 
protected< T extends JsonWebToken &ActionTokenKeyModel > Response handleActionToken (String tokenString, String execution, String clientId, String tabId)
 
private< T extends JsonWebToken > ActionTokenHandler< T > resolveActionTokenHandler (String actionId) throws VerificationException
 

非公開メンバ関数

boolean checkSsl ()
 
SessionCodeChecks checksForCode (String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
 
Response processFlowFromPath (String flowPath, AuthenticationSessionModel authSession, String errorMessage)
 
Response handleActionTokenVerificationException (ActionTokenContext<?> tokenContext, VerificationException ex, String eventError, String errorMessage)
 
Response registerRequest (String authSessionId, String code, String execution, String clientId, String tabId, boolean isPostRequest)
 
Response redirectToAfterBrokerLoginEndpoint (AuthenticationSessionModel authSession, boolean firstBrokerLogin)
 
void initLoginEvent (AuthenticationSessionModel authSession)
 
Response processRequireAction (final String authSessionId, final String code, String action, String clientId, String tabId)
 

非公開変数類

RealmModel realm
 
HttpRequest request
 
ClientConnection clientConnection
 
EventBuilder event
 

静的非公開変数類

static final Logger logger = Logger.getLogger(LoginActionsService.class)
 

詳解

著者
Stian Thorgersen

構築子と解体子

◆ LoginActionsService()

org.keycloak.services.resources.LoginActionsService.LoginActionsService ( RealmModel  realm,
EventBuilder  event 
)
inline
178  {
179  this.realm = realm;
180  this.event = event;
181  CacheControlUtil.noBackButtonCacheControlHeader();
182  }
EventBuilder event
Definition: LoginActionsService.java:143
RealmModel realm
Definition: LoginActionsService.java:126

関数詳解

◆ actionTokenProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.actionTokenProcessor ( UriInfo  uriInfo)
inlinestatic
158  {
159  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "executeActionToken");
160  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ authenticate()

Response org.keycloak.services.resources.LoginActionsService.authenticate ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

protocol independent login page entry point

引数
code
戻り値
248  {
249  event.event(EventType.LOGIN);
250 
251  SessionCodeChecks checks = checksForCode(authSessionId, code, execution, clientId, tabId, AUTHENTICATE_PATH);
252  if (!checks.verifyActiveAndValidAction(AuthenticationSessionModel.Action.AUTHENTICATE.name(), ClientSessionCode.ActionType.LOGIN)) {
253  return checks.getResponse();
254  }
255 
256  AuthenticationSessionModel authSession = checks.getAuthenticationSession();
257  boolean actionRequest = checks.isActionRequest();
258 
259  return processAuthentication(actionRequest, execution, authSession, null);
260  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
Response processAuthentication(boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:262
static final String AUTHENTICATE_PATH
Definition: LoginActionsService.java:112

◆ authenticateForm()

Response org.keycloak.services.resources.LoginActionsService.authenticateForm ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

URL called after login page. YOU SHOULD NEVER INVOKE THIS DIRECTLY!

引数
code
戻り値
319  {
320  return authenticate(authSessionId, code, execution, clientId, tabId);
321  }
Response authenticate(@QueryParam(AUTH_SESSION_ID) String authSessionId, @QueryParam(SESSION_CODE) String code, @QueryParam(Constants.EXECUTION) String execution, @QueryParam(Constants.CLIENT_ID) String clientId, @QueryParam(Constants.TAB_ID) String tabId)
Definition: LoginActionsService.java:244

◆ authenticationFormProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.authenticationFormProcessor ( UriInfo  uriInfo)
inlinestatic
150  {
151  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "authenticateForm");
152  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ brokerLoginFlow()

Response org.keycloak.services.resources.LoginActionsService.brokerLoginFlow ( String  authSessionId,
String  code,
String  execution,
String  clientId,
String  tabId,
String  flowPath 
)
inlineprotected
726  {
727  boolean firstBrokerLogin = flowPath.equals(FIRST_BROKER_LOGIN_PATH);
728 
729  EventType eventType = firstBrokerLogin ? EventType.IDENTITY_PROVIDER_FIRST_LOGIN : EventType.IDENTITY_PROVIDER_POST_LOGIN;
730  event.event(eventType);
731 
732  SessionCodeChecks checks = checksForCode(authSessionId, code, execution, clientId, tabId, flowPath);
733  if (!checks.verifyActiveAndValidAction(AuthenticationSessionModel.Action.AUTHENTICATE.name(), ClientSessionCode.ActionType.LOGIN)) {
734  return checks.getResponse();
735  }
736  event.detail(Details.CODE_ID, code);
737  final AuthenticationSessionModel authSession = checks.getAuthenticationSession();
738 
739  String noteKey = firstBrokerLogin ? AbstractIdpAuthenticator.BROKERED_CONTEXT_NOTE : PostBrokerLoginConstants.PBL_BROKERED_IDENTITY_CONTEXT;
740  SerializedBrokeredIdentityContext serializedCtx = SerializedBrokeredIdentityContext.readFromAuthenticationSession(authSession, noteKey);
741  if (serializedCtx == null) {
742  ServicesLogger.LOGGER.notFoundSerializedCtxInClientSession(noteKey);
743  throw new WebApplicationException(ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, "Not found serialized context in authenticationSession."));
744  }
745  BrokeredIdentityContext brokerContext = serializedCtx.deserialize(session, authSession);
746  final String identityProviderAlias = brokerContext.getIdpConfig().getAlias();
747 
748  String flowId = firstBrokerLogin ? brokerContext.getIdpConfig().getFirstBrokerLoginFlowId() : brokerContext.getIdpConfig().getPostBrokerLoginFlowId();
749  if (flowId == null) {
750  ServicesLogger.LOGGER.flowNotConfigForIDP(identityProviderAlias);
751  throw new WebApplicationException(ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, "Flow not configured for identity provider"));
752  }
753  AuthenticationFlowModel brokerLoginFlow = realm.getAuthenticationFlowById(flowId);
754  if (brokerLoginFlow == null) {
755  ServicesLogger.LOGGER.flowNotFoundForIDP(flowId, identityProviderAlias);
756  throw new WebApplicationException(ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, "Flow not found for identity provider"));
757  }
758 
759  event.detail(Details.IDENTITY_PROVIDER, identityProviderAlias)
760  .detail(Details.IDENTITY_PROVIDER_USERNAME, brokerContext.getUsername());
761 
762 
763  AuthenticationProcessor processor = new AuthenticationProcessor() {
764 
765  @Override
766  protected Response authenticationComplete() {
767  if (firstBrokerLogin) {
768  authSession.setAuthNote(AbstractIdpAuthenticator.FIRST_BROKER_LOGIN_SUCCESS, identityProviderAlias);
769  } else {
770  String authStateNoteKey = PostBrokerLoginConstants.PBL_AUTH_STATE_PREFIX + identityProviderAlias;
771  authSession.setAuthNote(authStateNoteKey, "true");
772  }
773 
774  return redirectToAfterBrokerLoginEndpoint(authSession, firstBrokerLogin);
775  }
776 
777  };
778 
779  return processFlow(checks.isActionRequest(), execution, authSession, flowPath, brokerLoginFlow, null, processor);
780  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
static final String FIRST_BROKER_LOGIN_PATH
Definition: LoginActionsService.java:116
Response brokerLoginFlow(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:726
Response redirectToAfterBrokerLoginEndpoint(AuthenticationSessionModel authSession, boolean firstBrokerLogin)
Definition: LoginActionsService.java:782
Response processFlow(boolean action, String execution, AuthenticationSessionModel authSession, String flowPath, AuthenticationFlowModel flow, String errorMessage, AuthenticationProcessor processor)
Definition: LoginActionsService.java:266
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ checksForCode()

SessionCodeChecks org.keycloak.services.resources.LoginActionsService.checksForCode ( String  authSessionId,
String  code,
String  execution,
String  clientId,
String  tabId,
String  flowPath 
)
inlineprivate
192  {
193  SessionCodeChecks res = new SessionCodeChecks(realm, session.getContext().getUri(), request, clientConnection, session, event, authSessionId, code, execution, clientId, tabId, flowPath);
194  res.initialVerify();
195  return res;
196  }
HttpRequest request
Definition: LoginActionsService.java:129
ClientConnection clientConnection
Definition: LoginActionsService.java:135
EventBuilder event
Definition: LoginActionsService.java:143
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ checkSsl()

boolean org.keycloak.services.resources.LoginActionsService.checkSsl ( )
inlineprivate
184  {
185  if (session.getContext().getUri().getBaseUri().getScheme().equals("https")) {
186  return true;
187  } else {
188  return !realm.getSslRequired().isRequired(clientConnection);
189  }
190  }
ClientConnection clientConnection
Definition: LoginActionsService.java:135
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ createAuthenticationSessionForClient()

AuthenticationSessionModel org.keycloak.services.resources.LoginActionsService.createAuthenticationSessionForClient ( ) throws UriBuilderException, IllegalArgumentException
inlinepackage
375  {
376  AuthenticationSessionModel authSession;
377 
378  // set up the account service as the endpoint to call.
379  ClientModel client = SystemClientUtil.getSystemClient(realm);
380 
381  RootAuthenticationSessionModel rootAuthSession = new AuthenticationSessionManager(session).createAuthenticationSession(realm, true);
382  authSession = rootAuthSession.createAuthenticationSession(client);
383 
384  authSession.setAction(AuthenticationSessionModel.Action.AUTHENTICATE.name());
385  //authSession.setNote(AuthenticationManager.END_AFTER_REQUIRED_ACTIONS, "true");
386  authSession.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
387  String redirectUri = Urls.accountBase(session.getContext().getUri().getBaseUri()).path("/").build(realm.getName()).toString();
388  authSession.setRedirectUri(redirectUri);
389  authSession.setClientNote(OIDCLoginProtocol.RESPONSE_TYPE_PARAM, OAuth2Constants.CODE);
390  authSession.setClientNote(OIDCLoginProtocol.REDIRECT_URI_PARAM, redirectUri);
391  authSession.setClientNote(OIDCLoginProtocol.ISSUER, Urls.realmIssuer(session.getContext().getUri().getBaseUri(), realm.getName()));
392 
393  return authSession;
394  }
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ executeActionToken()

Response org.keycloak.services.resources.LoginActionsService.executeActionToken ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(Constants.KEY) String  key,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

Handles a given token using the given token handler. If there is any VerificationException thrown in the handler, it is handled automatically here to reduce boilerplate code.

引数
key
execution
戻り値
431  {
432  return handleActionToken(key, execution, clientId, tabId);
433  }
protected< T extends JsonWebToken &ActionTokenKeyModel > Response handleActionToken(String tokenString, String execution, String clientId, String tabId)
Definition: LoginActionsService.java:435

◆ firstBrokerLoginGet()

Response org.keycloak.services.resources.LoginActionsService.firstBrokerLoginGet ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
691  {
692  return brokerLoginFlow(authSessionId, code, execution, clientId, tabId, FIRST_BROKER_LOGIN_PATH);
693  }
static final String FIRST_BROKER_LOGIN_PATH
Definition: LoginActionsService.java:116
Response brokerLoginFlow(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:726

◆ firstBrokerLoginPost()

Response org.keycloak.services.resources.LoginActionsService.firstBrokerLoginPost ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
701  {
702  return brokerLoginFlow(authSessionId, code, execution, clientId, tabId, FIRST_BROKER_LOGIN_PATH);
703  }
static final String FIRST_BROKER_LOGIN_PATH
Definition: LoginActionsService.java:116
Response brokerLoginFlow(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:726

◆ firstBrokerLoginProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.firstBrokerLoginProcessor ( UriInfo  uriInfo)
inlinestatic
166  {
167  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "firstBrokerLoginGet");
168  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ getLastExecutionUrl()

URI org.keycloak.services.resources.LoginActionsService.getLastExecutionUrl ( String  flowPath,
String  executionId,
String  clientId,
String  tabId 
)
inlineprotected
199  {
200  return new AuthenticationFlowURLHelper(session, realm, session.getContext().getUri())
201  .getLastExecutionUrl(flowPath, executionId, clientId, tabId);
202  }
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141
URI getLastExecutionUrl(String flowPath, String executionId, String clientId, String tabId)
Definition: LoginActionsService.java:199

◆ handleActionToken()

protected<T extends JsonWebToken & ActionTokenKeyModel> Response org.keycloak.services.resources.LoginActionsService.handleActionToken ( String  tokenString,
String  execution,
String  clientId,
String  tabId 
)
inlinepackage
435  {
436  T token;
437  ActionTokenHandler<T> handler;
438  ActionTokenContext<T> tokenContext;
439  String eventError = null;
440  String defaultErrorMessage = null;
441 
442  AuthenticationSessionModel authSession = null;
443 
444  // Setup client, so error page will contain "back to application" link
445  ClientModel client = null;
446  if (clientId != null) {
447  client = realm.getClientByClientId(clientId);
448  }
449  AuthenticationSessionManager authenticationSessionManager = new AuthenticationSessionManager(session);
450  if (client != null) {
451  session.getContext().setClient(client);
452  authSession = authenticationSessionManager.getCurrentAuthenticationSession(realm, client, tabId);
453  }
454 
455  event.event(EventType.EXECUTE_ACTION_TOKEN);
456 
457  // First resolve action token handler
458  try {
459  if (tokenString == null) {
460  throw new ExplainedTokenVerificationException(null, Errors.NOT_ALLOWED, Messages.INVALID_REQUEST);
461  }
462 
463  TokenVerifier<DefaultActionTokenKey> tokenVerifier = TokenVerifier.create(tokenString, DefaultActionTokenKey.class);
464  DefaultActionTokenKey aToken = tokenVerifier.getToken();
465 
466  event
467  .detail(Details.TOKEN_ID, aToken.getId())
468  .detail(Details.ACTION, aToken.getActionId())
469  .user(aToken.getUserId());
470 
471  handler = resolveActionTokenHandler(aToken.getActionId());
472  eventError = handler.getDefaultEventError();
473  defaultErrorMessage = handler.getDefaultErrorMessage();
474 
475  if (! realm.isEnabled()) {
476  throw new ExplainedTokenVerificationException(aToken, Errors.REALM_DISABLED, Messages.REALM_NOT_ENABLED);
477  }
478  if (! checkSsl()) {
479  throw new ExplainedTokenVerificationException(aToken, Errors.SSL_REQUIRED, Messages.HTTPS_REQUIRED);
480  }
481 
482  TokenVerifier<DefaultActionTokenKey> verifier = tokenVerifier
483  .withChecks(
484  // Token introspection checks
485  TokenVerifier.IS_ACTIVE,
486  new TokenVerifier.RealmUrlCheck(Urls.realmIssuer(session.getContext().getUri().getBaseUri(), realm.getName())),
487  ACTION_TOKEN_BASIC_CHECKS
488  );
489 
490  String kid = verifier.getHeader().getKeyId();
491  String algorithm = verifier.getHeader().getAlgorithm().name();
492 
493  SignatureVerifierContext signatureVerifier = session.getProvider(SignatureProvider.class, algorithm).verifier(kid);
494  verifier.verifierContext(signatureVerifier);
495 
496  verifier.verify();
497 
498  token = TokenVerifier.create(tokenString, handler.getTokenClass()).getToken();
499  } catch (TokenNotActiveException ex) {
500  if (authSession != null) {
501  event.clone().error(Errors.EXPIRED_CODE);
502  String flowPath = authSession.getClientNote(AuthorizationEndpointBase.APP_INITIATED_FLOW);
503  if (flowPath == null) {
504  flowPath = AUTHENTICATE_PATH;
505  }
506  AuthenticationProcessor.resetFlow(authSession, flowPath);
507 
508  // Process correct flow
509  return processFlowFromPath(flowPath, authSession, Messages.EXPIRED_ACTION_TOKEN_SESSION_EXISTS);
510  }
511 
512  return handleActionTokenVerificationException(null, ex, Errors.EXPIRED_CODE, Messages.EXPIRED_ACTION_TOKEN_NO_SESSION);
513  } catch (ExplainedTokenVerificationException ex) {
514  return handleActionTokenVerificationException(null, ex, ex.getErrorEvent(), ex.getMessage());
515  } catch (ExplainedVerificationException ex) {
516  return handleActionTokenVerificationException(null, ex, ex.getErrorEvent(), ex.getMessage());
517  } catch (VerificationException ex) {
518  return handleActionTokenVerificationException(null, ex, eventError, defaultErrorMessage);
519  }
520 
521  // Now proceed with the verification and handle the token
522  tokenContext = new ActionTokenContext(session, realm, session.getContext().getUri(), clientConnection, request, event, handler, execution, this::processFlow, this::brokerLoginFlow);
523 
524  try {
525  String tokenAuthSessionCompoundId = handler.getAuthenticationSessionIdFromToken(token, tokenContext, authSession);
526 
527  if (tokenAuthSessionCompoundId != null) {
528  // This can happen if the token contains ID but user opens the link in a new browser
529  String sessionId = AuthenticationSessionCompoundId.encoded(tokenAuthSessionCompoundId).getRootSessionId();
530  LoginActionsServiceChecks.checkNotLoggedInYet(tokenContext, sessionId);
531  }
532 
533  if (authSession == null) {
534  authSession = handler.startFreshAuthenticationSession(token, tokenContext);
535  tokenContext.setAuthenticationSession(authSession, true);
536  } else if (tokenAuthSessionCompoundId == null ||
537  ! LoginActionsServiceChecks.doesAuthenticationSessionFromCookieMatchOneFromToken(tokenContext, authSession, tokenAuthSessionCompoundId)) {
538  // There exists an authentication session but no auth session ID was received in the action token
539  logger.debugf("Authentication session in progress but no authentication session ID was found in action token %s, restarting.", token.getId());
540  authenticationSessionManager.removeAuthenticationSession(realm, authSession, false);
541 
542  authSession = handler.startFreshAuthenticationSession(token, tokenContext);
543  tokenContext.setAuthenticationSession(authSession, true);
544  }
545 
546  initLoginEvent(authSession);
547  event.event(handler.eventType());
548 
549  LoginActionsServiceChecks.checkIsUserValid(token, tokenContext);
550  LoginActionsServiceChecks.checkIsClientValid(token, tokenContext);
551 
552  session.getContext().setClient(authSession.getClient());
553 
554  TokenVerifier.createWithoutSignature(token)
555  .withChecks(handler.getVerifiers(tokenContext))
556  .verify();
557 
558  authSession = tokenContext.getAuthenticationSession();
559  event = tokenContext.getEvent();
560  event.event(handler.eventType());
561 
562  if (! handler.canUseTokenRepeatedly(token, tokenContext)) {
563  LoginActionsServiceChecks.checkTokenWasNotUsedYet(token, tokenContext);
564  authSession.setAuthNote(AuthenticationManager.INVALIDATE_ACTION_TOKEN, token.serializeKey());
565  }
566 
567  authSession.setAuthNote(DefaultActionTokenKey.ACTION_TOKEN_USER_ID, token.getUserId());
568 
569  authSession.setAuthNote(Constants.KEY, tokenString);
570 
571  return handler.handleToken(token, tokenContext);
572  } catch (ExplainedTokenVerificationException ex) {
573  return handleActionTokenVerificationException(tokenContext, ex, ex.getErrorEvent(), ex.getMessage());
574  } catch (LoginActionsServiceException ex) {
575  Response response = ex.getResponse();
576  return response == null
577  ? handleActionTokenVerificationException(tokenContext, ex, eventError, defaultErrorMessage)
578  : response;
579  } catch (VerificationException ex) {
580  return handleActionTokenVerificationException(tokenContext, ex, eventError, defaultErrorMessage);
581  }
582  }
private< T extends JsonWebToken > ActionTokenHandler< T > resolveActionTokenHandler(String actionId)
Definition: LoginActionsService.java:596
Response processFlowFromPath(String flowPath, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:584
HttpRequest request
Definition: LoginActionsService.java:129
void initLoginEvent(AuthenticationSessionModel authSession)
Definition: LoginActionsService.java:870
ClientConnection clientConnection
Definition: LoginActionsService.java:135
EventBuilder event
Definition: LoginActionsService.java:143
boolean checkSsl()
Definition: LoginActionsService.java:184
static final String AUTHENTICATE_PATH
Definition: LoginActionsService.java:112
RealmModel realm
Definition: LoginActionsService.java:126
Response handleActionTokenVerificationException(ActionTokenContext<?> tokenContext, VerificationException ex, String eventError, String errorMessage)
Definition: LoginActionsService.java:608
KeycloakSession session
Definition: LoginActionsService.java:141
static final Logger logger
Definition: LoginActionsService.java:110

◆ handleActionTokenVerificationException()

Response org.keycloak.services.resources.LoginActionsService.handleActionTokenVerificationException ( ActionTokenContext<?>  tokenContext,
VerificationException  ex,
String  eventError,
String  errorMessage 
)
inlineprivate
608  {
609  if (tokenContext != null && tokenContext.getAuthenticationSession() != null) {
610  new AuthenticationSessionManager(session).removeAuthenticationSession(realm, tokenContext.getAuthenticationSession(), true);
611  }
612 
613  event
614  .detail(Details.REASON, ex == null ? "<unknown>" : ex.getMessage())
615  .error(eventError == null ? Errors.INVALID_CODE : eventError);
616  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, errorMessage == null ? Messages.INVALID_CODE : errorMessage);
617  }
AuthenticationSessionModel getAuthenticationSession()
Definition: ActionTokenContext.java:134
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ initLoginEvent()

void org.keycloak.services.resources.LoginActionsService.initLoginEvent ( AuthenticationSessionModel  authSession)
inlineprivate
870  {
871  String responseType = authSession.getClientNote(OIDCLoginProtocol.RESPONSE_TYPE_PARAM);
872  if (responseType == null) {
873  responseType = "code";
874  }
875  String respMode = authSession.getClientNote(OIDCLoginProtocol.RESPONSE_MODE_PARAM);
876  OIDCResponseMode responseMode = OIDCResponseMode.parse(respMode, OIDCResponseType.parse(responseType));
877 
878  event.event(EventType.LOGIN).client(authSession.getClient())
879  .detail(Details.CODE_ID, authSession.getParentSession().getId())
880  .detail(Details.REDIRECT_URI, authSession.getRedirectUri())
881  .detail(Details.AUTH_METHOD, authSession.getProtocol())
882  .detail(Details.RESPONSE_TYPE, responseType)
883  .detail(Details.RESPONSE_MODE, responseMode.toString().toLowerCase());
884 
885  UserModel authenticatedUser = authSession.getAuthenticatedUser();
886  if (authenticatedUser != null) {
887  event.user(authenticatedUser)
888  .detail(Details.USERNAME, authenticatedUser.getUsername());
889  }
890 
891  String attemptedUsername = authSession.getAuthNote(AbstractUsernameFormAuthenticator.ATTEMPTED_USERNAME);
892  if (attemptedUsername != null) {
893  event.detail(Details.USERNAME, attemptedUsername);
894  }
895 
896  String rememberMe = authSession.getAuthNote(Details.REMEMBER_ME);
897  if (rememberMe==null || !rememberMe.equalsIgnoreCase("true")) {
898  rememberMe = "false";
899  }
900  event.detail(Details.REMEMBER_ME, rememberMe);
901 
902  Map<String, String> userSessionNotes = authSession.getUserSessionNotes();
903  String identityProvider = userSessionNotes.get(Details.IDENTITY_PROVIDER);
904  if (identityProvider != null) {
905  event.detail(Details.IDENTITY_PROVIDER, identityProvider)
906  .detail(Details.IDENTITY_PROVIDER_USERNAME, userSessionNotes.get(Details.IDENTITY_PROVIDER_USERNAME));
907  }
908  }

◆ loginActionsBaseUrl() [1/2]

static UriBuilder org.keycloak.services.resources.LoginActionsService.loginActionsBaseUrl ( UriInfo  uriInfo)
inlinestatic
145  {
146  UriBuilder baseUriBuilder = uriInfo.getBaseUriBuilder();
147  return loginActionsBaseUrl(baseUriBuilder);
148  }
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ loginActionsBaseUrl() [2/2]

static UriBuilder org.keycloak.services.resources.LoginActionsService.loginActionsBaseUrl ( UriBuilder  baseUriBuilder)
inlinestatic
174  {
175  return baseUriBuilder.path(RealmsResource.class).path(RealmsResource.class, "getLoginActionsService");
176  }

◆ postBrokerLoginGet()

Response org.keycloak.services.resources.LoginActionsService.postBrokerLoginGet ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
711  {
712  return brokerLoginFlow(authSessionId, code, execution, clientId, tabId, POST_BROKER_LOGIN_PATH);
713  }
Response brokerLoginFlow(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:726
static final String POST_BROKER_LOGIN_PATH
Definition: LoginActionsService.java:117

◆ postBrokerLoginPost()

Response org.keycloak.services.resources.LoginActionsService.postBrokerLoginPost ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
721  {
722  return brokerLoginFlow(authSessionId, code, execution, clientId, tabId, POST_BROKER_LOGIN_PATH);
723  }
Response brokerLoginFlow(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:726
static final String POST_BROKER_LOGIN_PATH
Definition: LoginActionsService.java:117

◆ postBrokerLoginProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.postBrokerLoginProcessor ( UriInfo  uriInfo)
inlinestatic
170  {
171  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "postBrokerLoginGet");
172  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ processAuthentication()

Response org.keycloak.services.resources.LoginActionsService.processAuthentication ( boolean  action,
String  execution,
AuthenticationSessionModel  authSession,
String  errorMessage 
)
inlineprotected
262  {
263  return processFlow(action, execution, authSession, AUTHENTICATE_PATH, AuthenticationFlowResolver.resolveBrowserFlow(authSession), errorMessage, new AuthenticationProcessor());
264  }
Response processFlow(boolean action, String execution, AuthenticationSessionModel authSession, String flowPath, AuthenticationFlowModel flow, String errorMessage, AuthenticationProcessor processor)
Definition: LoginActionsService.java:266
static final String AUTHENTICATE_PATH
Definition: LoginActionsService.java:112

◆ processConsent()

Response org.keycloak.services.resources.LoginActionsService.processConsent ( final MultivaluedMap< String, String >  formData)
inline

OAuth grant page. You should not invoked this directly!

引数
formData
戻り値
809  {
810  event.event(EventType.LOGIN);
811  String code = formData.getFirst(SESSION_CODE);
812  String clientId = session.getContext().getUri().getQueryParameters().getFirst(Constants.CLIENT_ID);
813  String tabId = session.getContext().getUri().getQueryParameters().getFirst(Constants.TAB_ID);
814  SessionCodeChecks checks = checksForCode(null, code, null, clientId, tabId, REQUIRED_ACTION);
815  if (!checks.verifyRequiredAction(AuthenticationSessionModel.Action.OAUTH_GRANT.name())) {
816  return checks.getResponse();
817  }
818 
819  AuthenticationSessionModel authSession = checks.getAuthenticationSession();
820 
821  initLoginEvent(authSession);
822 
823  UserModel user = authSession.getAuthenticatedUser();
824  ClientModel client = authSession.getClient();
825 
826 
827  if (formData.containsKey("cancel")) {
828  LoginProtocol protocol = session.getProvider(LoginProtocol.class, authSession.getProtocol());
829  protocol.setRealm(realm)
830  .setHttpHeaders(headers)
831  .setUriInfo(session.getContext().getUri())
832  .setEventBuilder(event);
833  Response response = protocol.sendError(authSession, Error.CONSENT_DENIED);
834  event.error(Errors.REJECTED_BY_USER);
835  return response;
836  }
837 
838  UserConsentModel grantedConsent = session.users().getConsentByClient(realm, user.getId(), client.getId());
839  if (grantedConsent == null) {
840  grantedConsent = new UserConsentModel(client);
841  session.users().addConsent(realm, user.getId(), grantedConsent);
842  }
843 
844  // Update may not be required if all clientScopes were already granted (May happen for example with prompt=consent)
845  boolean updateConsentRequired = false;
846 
847  for (String clientScopeId : authSession.getClientScopes()) {
848  ClientScopeModel clientScope = KeycloakModelUtils.findClientScopeById(realm, clientScopeId);
849  if (clientScope != null) {
850  if (!grantedConsent.isClientScopeGranted(clientScope)) {
851  grantedConsent.addGrantedClientScope(clientScope);
852  updateConsentRequired = true;
853  }
854  } else {
855  logger.warnf("Client scope with ID '%s' not found", clientScopeId);
856  }
857  }
858 
859  if (updateConsentRequired) {
860  session.users().updateConsent(realm, user.getId(), grantedConsent);
861  }
862 
863  event.detail(Details.CONSENT, Details.CONSENT_VALUE_CONSENT_GRANTED);
864  event.success();
865 
866  ClientSessionContext clientSessionCtx = AuthenticationProcessor.attachSession(authSession, null, session, realm, clientConnection, event);
867  return AuthenticationManager.redirectAfterSuccessfulFlow(session, realm, clientSessionCtx.getClientSession().getUserSession(), clientSessionCtx, request, session.getContext().getUri(), clientConnection, event, authSession.getProtocol());
868  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
HttpRequest request
Definition: LoginActionsService.java:129
void initLoginEvent(AuthenticationSessionModel authSession)
Definition: LoginActionsService.java:870
ClientConnection clientConnection
Definition: LoginActionsService.java:135
HttpHeaders headers
Definition: LoginActionsService.java:132
EventBuilder event
Definition: LoginActionsService.java:143
static final String SESSION_CODE
Definition: LoginActionsService.java:123
static final String REQUIRED_ACTION
Definition: LoginActionsService.java:115
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141
static final Logger logger
Definition: LoginActionsService.java:110

◆ processFlow()

Response org.keycloak.services.resources.LoginActionsService.processFlow ( boolean  action,
String  execution,
AuthenticationSessionModel  authSession,
String  flowPath,
AuthenticationFlowModel  flow,
String  errorMessage,
AuthenticationProcessor  processor 
)
inlineprotected
266  {
267  processor.setAuthenticationSession(authSession)
268  .setFlowPath(flowPath)
269  .setBrowserFlow(true)
270  .setFlowId(flow.getId())
271  .setConnection(clientConnection)
272  .setEventBuilder(event)
273  .setRealm(realm)
274  .setSession(session)
275  .setUriInfo(session.getContext().getUri())
276  .setRequest(request);
277  if (errorMessage != null) {
278  processor.setForwardedErrorMessage(new FormMessage(null, errorMessage));
279  }
280 
281  // Check the forwarded error message, which was set by previous HTTP request
282  String forwardedErrorMessage = authSession.getAuthNote(FORWARDED_ERROR_MESSAGE_NOTE);
283  if (forwardedErrorMessage != null) {
284  authSession.removeAuthNote(FORWARDED_ERROR_MESSAGE_NOTE);
285  processor.setForwardedErrorMessage(new FormMessage(null, forwardedErrorMessage));
286  }
287 
288 
289  Response response;
290  try {
291  if (action) {
292  response = processor.authenticationAction(execution);
293  } else {
294  response = processor.authenticate();
295  }
296  } catch (WebApplicationException e) {
297  response = e.getResponse();
298  authSession = processor.getAuthenticationSession();
299  } catch (Exception e) {
300  response = processor.handleBrowserException(e);
301  authSession = processor.getAuthenticationSession(); // Could be changed (eg. Forked flow)
302  }
303 
304  return BrowserHistoryHelper.getInstance().saveResponseAndRedirect(session, authSession, response, action, request);
305  }
static final String FORWARDED_ERROR_MESSAGE_NOTE
Definition: LoginActionsService.java:121
HttpRequest request
Definition: LoginActionsService.java:129
ClientConnection clientConnection
Definition: LoginActionsService.java:135
EventBuilder event
Definition: LoginActionsService.java:143
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ processFlowFromPath()

Response org.keycloak.services.resources.LoginActionsService.processFlowFromPath ( String  flowPath,
AuthenticationSessionModel  authSession,
String  errorMessage 
)
inlineprivate
584  {
585  if (AUTHENTICATE_PATH.equals(flowPath)) {
586  return processAuthentication(false, null, authSession, errorMessage);
587  } else if (REGISTRATION_PATH.equals(flowPath)) {
588  return processRegistration(false, null, authSession, errorMessage);
589  } else if (RESET_CREDENTIALS_PATH.equals(flowPath)) {
590  return processResetCredentials(false, null, authSession, errorMessage);
591  } else {
592  return ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, errorMessage == null ? Messages.INVALID_REQUEST : errorMessage);
593  }
594  }
Response processAuthentication(boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:262
static final String REGISTRATION_PATH
Definition: LoginActionsService.java:113
Response processRegistration(boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:626
static final String RESET_CREDENTIALS_PATH
Definition: LoginActionsService.java:114
static final String AUTHENTICATE_PATH
Definition: LoginActionsService.java:112
Response processResetCredentials(boolean actionRequest, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:619
KeycloakSession session
Definition: LoginActionsService.java:141

◆ processRegister()

Response org.keycloak.services.resources.LoginActionsService.processRegister ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

Registration

引数
code
戻り値
660  {
661  return registerRequest(authSessionId, code, execution, clientId, tabId,true);
662  }
Response registerRequest(String authSessionId, String code, String execution, String clientId, String tabId, boolean isPostRequest)
Definition: LoginActionsService.java:665

◆ processRegistration()

Response org.keycloak.services.resources.LoginActionsService.processRegistration ( boolean  action,
String  execution,
AuthenticationSessionModel  authSession,
String  errorMessage 
)
inlineprotected
626  {
627  return processFlow(action, execution, authSession, REGISTRATION_PATH, realm.getRegistrationFlow(), errorMessage, new AuthenticationProcessor());
628  }
static final String REGISTRATION_PATH
Definition: LoginActionsService.java:113
Response processFlow(boolean action, String execution, AuthenticationSessionModel authSession, String flowPath, AuthenticationFlowModel flow, String errorMessage, AuthenticationProcessor processor)
Definition: LoginActionsService.java:266
RealmModel realm
Definition: LoginActionsService.java:126

◆ processRequireAction()

Response org.keycloak.services.resources.LoginActionsService.processRequireAction ( final String  authSessionId,
final String  code,
String  action,
String  clientId,
String  tabId 
)
inlineprivate
930  {
931  event.event(EventType.CUSTOM_REQUIRED_ACTION);
932 
933  SessionCodeChecks checks = checksForCode(authSessionId, code, action, clientId, tabId, REQUIRED_ACTION);
934  if (!checks.verifyRequiredAction(action)) {
935  return checks.getResponse();
936  }
937 
938  AuthenticationSessionModel authSession = checks.getAuthenticationSession();
939  if (!checks.isActionRequest()) {
940  initLoginEvent(authSession);
941  event.event(EventType.CUSTOM_REQUIRED_ACTION);
942  return AuthenticationManager.nextActionAfterAuthentication(session, authSession, clientConnection, request, session.getContext().getUri(), event);
943  }
944 
945  initLoginEvent(authSession);
946  event.event(EventType.CUSTOM_REQUIRED_ACTION);
947  event.detail(Details.CUSTOM_REQUIRED_ACTION, action);
948 
949  RequiredActionFactory factory = (RequiredActionFactory)session.getKeycloakSessionFactory().getProviderFactory(RequiredActionProvider.class, action);
950  if (factory == null) {
951  ServicesLogger.LOGGER.actionProviderNull();
952  event.error(Errors.INVALID_CODE);
953  throw new WebApplicationException(ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, Messages.INVALID_CODE));
954  }
955  RequiredActionContextResult context = new RequiredActionContextResult(authSession, realm, event, session, request, authSession.getAuthenticatedUser(), factory) {
956  @Override
957  public void ignore() {
958  throw new RuntimeException("Cannot call ignore within processAction()");
959  }
960  };
961  RequiredActionProvider provider = null;
962  try {
963  provider = AuthenticationManager.createRequiredAction(context);
964  } catch (AuthenticationFlowException e) {
965  if (e.getResponse() != null) {
966  return e.getResponse();
967  }
968  throw new WebApplicationException(ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, Messages.DISPLAY_UNSUPPORTED));
969  }
970 
971 
972  Response response;
973  provider.processAction(context);
974 
975  if (action != null) {
976  authSession.setAuthNote(AuthenticationProcessor.LAST_PROCESSED_EXECUTION, action);
977  }
978 
979  if (context.getStatus() == RequiredActionContext.Status.SUCCESS) {
980  event.clone().success();
981  initLoginEvent(authSession);
982  event.event(EventType.LOGIN);
983  authSession.removeRequiredAction(factory.getId());
984  authSession.getAuthenticatedUser().removeRequiredAction(factory.getId());
985  authSession.removeAuthNote(AuthenticationProcessor.CURRENT_AUTHENTICATION_EXECUTION);
986 
987  response = AuthenticationManager.nextActionAfterAuthentication(session, authSession, clientConnection, request, session.getContext().getUri(), event);
988  } else if (context.getStatus() == RequiredActionContext.Status.CHALLENGE) {
989  response = context.getChallenge();
990  } else if (context.getStatus() == RequiredActionContext.Status.FAILURE) {
991  LoginProtocol protocol = context.getSession().getProvider(LoginProtocol.class, authSession.getProtocol());
992  protocol.setRealm(context.getRealm())
993  .setHttpHeaders(context.getHttpRequest().getHttpHeaders())
994  .setUriInfo(context.getUriInfo())
995  .setEventBuilder(event);
996 
997  event.detail(Details.CUSTOM_REQUIRED_ACTION, action);
998  response = protocol.sendError(authSession, Error.CONSENT_DENIED);
999  event.error(Errors.REJECTED_BY_USER);
1000  } else {
1001  throw new RuntimeException("Unreachable");
1002  }
1003 
1004  return BrowserHistoryHelper.getInstance().saveResponseAndRedirect(session, authSession, response, true, request);
1005  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
HttpRequest request
Definition: LoginActionsService.java:129
void initLoginEvent(AuthenticationSessionModel authSession)
Definition: LoginActionsService.java:870
ClientConnection clientConnection
Definition: LoginActionsService.java:135
EventBuilder event
Definition: LoginActionsService.java:143
static final String REQUIRED_ACTION
Definition: LoginActionsService.java:115
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ processResetCredentials()

Response org.keycloak.services.resources.LoginActionsService.processResetCredentials ( boolean  actionRequest,
String  execution,
AuthenticationSessionModel  authSession,
String  errorMessage 
)
inlineprotected
619  {
620  AuthenticationProcessor authProcessor = new ResetCredentialsActionTokenHandler.ResetCredsAuthenticationProcessor();
621 
622  return processFlow(actionRequest, execution, authSession, RESET_CREDENTIALS_PATH, realm.getResetCredentialsFlow(), errorMessage, authProcessor);
623  }
static final String RESET_CREDENTIALS_PATH
Definition: LoginActionsService.java:114
Response processFlow(boolean action, String execution, AuthenticationSessionModel authSession, String flowPath, AuthenticationFlowModel flow, String errorMessage, AuthenticationProcessor processor)
Definition: LoginActionsService.java:266
RealmModel realm
Definition: LoginActionsService.java:126

◆ redirectToAfterBrokerLoginEndpoint() [1/2]

Response org.keycloak.services.resources.LoginActionsService.redirectToAfterBrokerLoginEndpoint ( AuthenticationSessionModel  authSession,
boolean  firstBrokerLogin 
)
inlineprivate
782  {
783  return redirectToAfterBrokerLoginEndpoint(session, realm, session.getContext().getUri(), authSession, firstBrokerLogin);
784  }
Response redirectToAfterBrokerLoginEndpoint(AuthenticationSessionModel authSession, boolean firstBrokerLogin)
Definition: LoginActionsService.java:782
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ redirectToAfterBrokerLoginEndpoint() [2/2]

static Response org.keycloak.services.resources.LoginActionsService.redirectToAfterBrokerLoginEndpoint ( KeycloakSession  session,
RealmModel  realm,
UriInfo  uriInfo,
AuthenticationSessionModel  authSession,
boolean  firstBrokerLogin 
)
inlinestatic
786  {
787  ClientSessionCode<AuthenticationSessionModel> accessCode = new ClientSessionCode<>(session, realm, authSession);
788  authSession.getParentSession().setTimestamp(Time.currentTime());
789 
790  String clientId = authSession.getClient().getClientId();
791  String tabId = authSession.getTabId();
792  URI redirect = firstBrokerLogin ? Urls.identityProviderAfterFirstBrokerLogin(uriInfo.getBaseUri(), realm.getName(), accessCode.getOrGenerateCode(), clientId, tabId) :
793  Urls.identityProviderAfterPostBrokerLogin(uriInfo.getBaseUri(), realm.getName(), accessCode.getOrGenerateCode(), clientId, tabId) ;
794  logger.debugf("Redirecting to '%s' ", redirect);
795 
796  return Response.status(302).location(redirect).build();
797  }
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141
static final Logger logger
Definition: LoginActionsService.java:110

◆ registerPage()

Response org.keycloak.services.resources.LoginActionsService.registerPage ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

protocol independent registration page entry point

引数
code
戻り値
643  {
644  return registerRequest(authSessionId, code, execution, clientId, tabId,false);
645  }
Response registerRequest(String authSessionId, String code, String execution, String clientId, String tabId, boolean isPostRequest)
Definition: LoginActionsService.java:665

◆ registerRequest()

Response org.keycloak.services.resources.LoginActionsService.registerRequest ( String  authSessionId,
String  code,
String  execution,
String  clientId,
String  tabId,
boolean  isPostRequest 
)
inlineprivate
665  {
666  event.event(EventType.REGISTER);
667  if (!realm.isRegistrationAllowed()) {
668  event.error(Errors.REGISTRATION_DISABLED);
669  return ErrorPage.error(session, null, Response.Status.BAD_REQUEST, Messages.REGISTRATION_NOT_ALLOWED);
670  }
671 
672  SessionCodeChecks checks = checksForCode(authSessionId, code, execution, clientId, tabId, REGISTRATION_PATH);
673  if (!checks.verifyActiveAndValidAction(AuthenticationSessionModel.Action.AUTHENTICATE.name(), ClientSessionCode.ActionType.LOGIN)) {
674  return checks.getResponse();
675  }
676 
677  AuthenticationSessionModel authSession = checks.getAuthenticationSession();
678 
679  AuthenticationManager.expireIdentityCookie(realm, session.getContext().getUri(), clientConnection);
680 
681  return processRegistration(checks.isActionRequest(), execution, authSession, null);
682  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
static final String REGISTRATION_PATH
Definition: LoginActionsService.java:113
ClientConnection clientConnection
Definition: LoginActionsService.java:135
Response processRegistration(boolean action, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:626
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141

◆ registrationFormProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.registrationFormProcessor ( UriInfo  uriInfo)
inlinestatic
162  {
163  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "processRegister");
164  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ requiredActionGET()

Response org.keycloak.services.resources.LoginActionsService.requiredActionGET ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) final String  code,
@QueryParam(Constants.EXECUTION) String  action,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
926  {
927  return processRequireAction(authSessionId, code, action, clientId, tabId);
928  }
Response processRequireAction(final String authSessionId, final String code, String action, String clientId, String tabId)
Definition: LoginActionsService.java:930

◆ requiredActionPOST()

Response org.keycloak.services.resources.LoginActionsService.requiredActionPOST ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) final String  code,
@QueryParam(Constants.EXECUTION) String  action,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline
916  {
917  return processRequireAction(authSessionId, code, action, clientId, tabId);
918  }
Response processRequireAction(final String authSessionId, final String code, String action, String clientId, String tabId)
Definition: LoginActionsService.java:930

◆ requiredActionProcessor()

static UriBuilder org.keycloak.services.resources.LoginActionsService.requiredActionProcessor ( UriInfo  uriInfo)
inlinestatic
154  {
155  return loginActionsBaseUrl(uriInfo).path(LoginActionsService.class, "requiredActionPOST");
156  }
LoginActionsService(RealmModel realm, EventBuilder event)
Definition: LoginActionsService.java:178
static UriBuilder loginActionsBaseUrl(UriInfo uriInfo)
Definition: LoginActionsService.java:145

◆ resetCredentials()

Response org.keycloak.services.resources.LoginActionsService.resetCredentials ( String  authSessionId,
String  code,
String  execution,
String  clientId,
String  tabId 
)
inlineprotected
引数
code
execution
戻り値
401  {
402  SessionCodeChecks checks = checksForCode(authSessionId, code, execution, clientId, tabId, RESET_CREDENTIALS_PATH);
403  if (!checks.verifyActiveAndValidAction(AuthenticationSessionModel.Action.AUTHENTICATE.name(), ClientSessionCode.ActionType.USER)) {
404  return checks.getResponse();
405  }
406  final AuthenticationSessionModel authSession = checks.getAuthenticationSession();
407 
408  if (!realm.isResetPasswordAllowed()) {
409  event.error(Errors.NOT_ALLOWED);
410  return ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, Messages.RESET_CREDENTIAL_NOT_ALLOWED);
411 
412  }
413 
414  return processResetCredentials(checks.isActionRequest(), execution, authSession, null);
415  }
SessionCodeChecks checksForCode(String authSessionId, String code, String execution, String clientId, String tabId, String flowPath)
Definition: LoginActionsService.java:192
static final String RESET_CREDENTIALS_PATH
Definition: LoginActionsService.java:114
RealmModel realm
Definition: LoginActionsService.java:126
Response processResetCredentials(boolean actionRequest, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:619
KeycloakSession session
Definition: LoginActionsService.java:141

◆ resetCredentialsGET()

Response org.keycloak.services.resources.LoginActionsService.resetCredentialsGET ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

Endpoint for executing reset credentials flow. If token is null, a authentication session is created with the account service as the client. Successful reset sends you to the account page. Note, account service must be enabled.

引数
code
execution
戻り値
354  {
355  ClientModel client = realm.getClientByClientId(clientId);
356  AuthenticationSessionModel authSession = new AuthenticationSessionManager(session).getCurrentAuthenticationSession(realm, client, tabId);
357 
358  // we allow applications to link to reset credentials without going through OAuth or SAML handshakes
359  if (authSession == null && code == null) {
360  if (!realm.isResetPasswordAllowed()) {
361  event.event(EventType.RESET_PASSWORD);
362  event.error(Errors.NOT_ALLOWED);
363  return ErrorPage.error(session, authSession, Response.Status.BAD_REQUEST, Messages.RESET_CREDENTIAL_NOT_ALLOWED);
364 
365  }
366  authSession = createAuthenticationSessionForClient();
367  return processResetCredentials(false, null, authSession, null);
368  }
369 
370  event.event(EventType.RESET_PASSWORD);
371  return resetCredentials(authSessionId, code, execution, clientId, tabId);
372  }
Response resetCredentials(String authSessionId, String code, String execution, String clientId, String tabId)
Definition: LoginActionsService.java:401
RealmModel realm
Definition: LoginActionsService.java:126
Response processResetCredentials(boolean actionRequest, String execution, AuthenticationSessionModel authSession, String errorMessage)
Definition: LoginActionsService.java:619
KeycloakSession session
Definition: LoginActionsService.java:141
AuthenticationSessionModel createAuthenticationSessionForClient()
Definition: LoginActionsService.java:374

◆ resetCredentialsPOST()

Response org.keycloak.services.resources.LoginActionsService.resetCredentialsPOST ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(SESSION_CODE) String  code,
@QueryParam(Constants.EXECUTION) String  execution,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId,
@QueryParam(Constants.KEY) String  key 
)
inline
330  {
331  if (key != null) {
332  return handleActionToken(key, execution, clientId, tabId);
333  }
334 
335  event.event(EventType.RESET_PASSWORD);
336 
337  return resetCredentials(authSessionId, code, execution, clientId, tabId);
338  }
protected< T extends JsonWebToken &ActionTokenKeyModel > Response handleActionToken(String tokenString, String execution, String clientId, String tabId)
Definition: LoginActionsService.java:435
Response resetCredentials(String authSessionId, String code, String execution, String clientId, String tabId)
Definition: LoginActionsService.java:401

◆ resolveActionTokenHandler()

private<T extends JsonWebToken> ActionTokenHandler<T> org.keycloak.services.resources.LoginActionsService.resolveActionTokenHandler ( String  actionId) throws VerificationException
inlinepackage
596  {
597  if (actionId == null) {
598  throw new VerificationException("Action token operation not set");
599  }
600  ActionTokenHandler<T> handler = session.getProvider(ActionTokenHandler.class, actionId);
601 
602  if (handler == null) {
603  throw new VerificationException("Invalid action token operation");
604  }
605  return handler;
606  }
KeycloakSession session
Definition: LoginActionsService.java:141

◆ restartSession()

Response org.keycloak.services.resources.LoginActionsService.restartSession ( @QueryParam(AUTH_SESSION_ID) String  authSessionId,
@QueryParam(Constants.CLIENT_ID) String  clientId,
@QueryParam(Constants.TAB_ID) String  tabId 
)
inline

protocol independent page for restart of the flow

戻り値
214  {
215  event.event(EventType.RESTART_AUTHENTICATION);
216  SessionCodeChecks checks = new SessionCodeChecks(realm, session.getContext().getUri(), request, clientConnection, session, event, authSessionId, null, null, clientId, tabId, null);
217 
218  AuthenticationSessionModel authSession = checks.initialVerifyAuthSession();
219  if (authSession == null) {
220  return checks.getResponse();
221  }
222 
223  String flowPath = authSession.getClientNote(AuthorizationEndpointBase.APP_INITIATED_FLOW);
224  if (flowPath == null) {
225  flowPath = AUTHENTICATE_PATH;
226  }
227 
228  AuthenticationProcessor.resetFlow(authSession, flowPath);
229 
230  URI redirectUri = getLastExecutionUrl(flowPath, null, authSession.getClient().getClientId(), tabId);
231  logger.debugf("Flow restart requested. Redirecting to %s", redirectUri);
232  return Response.status(Response.Status.FOUND).location(redirectUri).build();
233  }
HttpRequest request
Definition: LoginActionsService.java:129
ClientConnection clientConnection
Definition: LoginActionsService.java:135
EventBuilder event
Definition: LoginActionsService.java:143
static final String AUTHENTICATE_PATH
Definition: LoginActionsService.java:112
RealmModel realm
Definition: LoginActionsService.java:126
KeycloakSession session
Definition: LoginActionsService.java:141
URI getLastExecutionUrl(String flowPath, String executionId, String clientId, String tabId)
Definition: LoginActionsService.java:199
static final Logger logger
Definition: LoginActionsService.java:110

メンバ詳解

◆ AUTH_SESSION_ID

final String org.keycloak.services.resources.LoginActionsService.AUTH_SESSION_ID = "auth_session_id"
static

◆ AUTHENTICATE_PATH

final String org.keycloak.services.resources.LoginActionsService.AUTHENTICATE_PATH = "authenticate"
static

◆ clientConnection

ClientConnection org.keycloak.services.resources.LoginActionsService.clientConnection
private

◆ event

EventBuilder org.keycloak.services.resources.LoginActionsService.event
private

◆ FIRST_BROKER_LOGIN_PATH

final String org.keycloak.services.resources.LoginActionsService.FIRST_BROKER_LOGIN_PATH = "first-broker-login"
static

◆ FORWARDED_ERROR_MESSAGE_NOTE

final String org.keycloak.services.resources.LoginActionsService.FORWARDED_ERROR_MESSAGE_NOTE = "forwardedErrorMessage"
static

◆ headers

HttpHeaders org.keycloak.services.resources.LoginActionsService.headers
protected

◆ logger

final Logger org.keycloak.services.resources.LoginActionsService.logger = Logger.getLogger(LoginActionsService.class)
staticprivate

◆ POST_BROKER_LOGIN_PATH

final String org.keycloak.services.resources.LoginActionsService.POST_BROKER_LOGIN_PATH = "post-broker-login"
static

◆ providers

Providers org.keycloak.services.resources.LoginActionsService.providers
protected

◆ realm

RealmModel org.keycloak.services.resources.LoginActionsService.realm
private

◆ REGISTRATION_PATH

final String org.keycloak.services.resources.LoginActionsService.REGISTRATION_PATH = "registration"
static

◆ request

HttpRequest org.keycloak.services.resources.LoginActionsService.request
private

◆ REQUIRED_ACTION

final String org.keycloak.services.resources.LoginActionsService.REQUIRED_ACTION = "required-action"
static

◆ RESET_CREDENTIALS_PATH

final String org.keycloak.services.resources.LoginActionsService.RESET_CREDENTIALS_PATH = "reset-credentials"
static

◆ RESTART_PATH

final String org.keycloak.services.resources.LoginActionsService.RESTART_PATH = "restart"
static

◆ session

KeycloakSession org.keycloak.services.resources.LoginActionsService.session
protected

◆ SESSION_CODE

final String org.keycloak.services.resources.LoginActionsService.SESSION_CODE = "session_code"
static

このクラス詳解は次のファイルから抽出されました: