keycloak-service
公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 限定公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.protocol.AuthorizationEndpointBase クラスabstract
org.keycloak.protocol.AuthorizationEndpointBase の継承関係図
Inheritance graph
org.keycloak.protocol.AuthorizationEndpointBase 連携図
Collaboration graph

公開メンバ関数

 AuthorizationEndpointBase (RealmModel realm, EventBuilder event)
 

静的公開変数類

static final String APP_INITIATED_FLOW = "APP_INITIATED_FLOW"
 

限定公開メンバ関数

AuthenticationProcessor createProcessor (AuthenticationSessionModel authSession, String flowId, String flowPath)
 
Response handleBrowserAuthenticationRequest (AuthenticationSessionModel authSession, LoginProtocol protocol, boolean isPassive, boolean redirectToAuthentication)
 
AuthenticationFlowModel getAuthenticationFlow (AuthenticationSessionModel authSession)
 
void checkSsl ()
 
void checkRealm ()
 
AuthenticationSessionModel createAuthenticationSession (ClientModel client, String requestState)
 

限定公開変数類

RealmModel realm
 
EventBuilder event
 
AuthenticationManager authManager
 
HttpHeaders headers
 
HttpRequest httpRequest
 
KeycloakSession session
 
ClientConnection clientConnection
 

静的非公開変数類

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

詳解

Common base class for Authorization REST endpoints implementation, which have to be implemented by each protocol.

著者
Vlastimil Elias (velias at redhat dot com)

構築子と解体子

◆ AuthorizationEndpointBase()

org.keycloak.protocol.AuthorizationEndpointBase.AuthorizationEndpointBase ( RealmModel  realm,
EventBuilder  event 
)
inline
73  {
74  this.realm = realm;
75  this.event = event;
76  }
EventBuilder event
Definition: AuthorizationEndpointBase.java:61
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

関数詳解

◆ checkRealm()

void org.keycloak.protocol.AuthorizationEndpointBase.checkRealm ( )
inlineprotected
159  {
160  if (!realm.isEnabled()) {
161  event.error(Errors.REALM_DISABLED);
162  throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.REALM_NOT_ENABLED);
163  }
164  }
KeycloakSession session
Definition: AuthorizationEndpointBase.java:69
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

◆ checkSsl()

void org.keycloak.protocol.AuthorizationEndpointBase.checkSsl ( )
inlineprotected
152  {
153  if (!session.getContext().getUri().getBaseUri().getScheme().equals("https") && realm.getSslRequired().isRequired(clientConnection)) {
154  event.error(Errors.SSL_REQUIRED);
155  throw new ErrorPageException(session, Response.Status.BAD_REQUEST, Messages.HTTPS_REQUIRED);
156  }
157  }
ClientConnection clientConnection
Definition: AuthorizationEndpointBase.java:71
KeycloakSession session
Definition: AuthorizationEndpointBase.java:69
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

◆ createAuthenticationSession()

AuthenticationSessionModel org.keycloak.protocol.AuthorizationEndpointBase.createAuthenticationSession ( ClientModel  client,
String  requestState 
)
inlineprotected
166  {
167  AuthenticationSessionManager manager = new AuthenticationSessionManager(session);
168  RootAuthenticationSessionModel rootAuthSession = manager.getCurrentRootAuthenticationSession(realm);
169 
170  AuthenticationSessionModel authSession;
171 
172  if (rootAuthSession != null) {
173  authSession = rootAuthSession.createAuthenticationSession(client);
174 
175  logger.debugf("Sent request to authz endpoint. Root authentication session with ID '%s' exists. Client is '%s' . Created new authentication session with tab ID: %s",
176  rootAuthSession.getId(), client.getClientId(), authSession.getTabId());
177  } else {
178  UserSessionCrossDCManager userSessionCrossDCManager = new UserSessionCrossDCManager(session);
179  UserSessionModel userSession = userSessionCrossDCManager.getUserSessionIfExistsRemotely(manager, realm);
180 
181  if (userSession != null) {
182  String userSessionId = userSession.getId();
183  rootAuthSession = session.authenticationSessions().createRootAuthenticationSession(userSessionId, realm);
184  authSession = rootAuthSession.createAuthenticationSession(client);
185  logger.debugf("Sent request to authz endpoint. We don't have root authentication session with ID '%s' but we have userSession." +
186  "Re-created root authentication session with same ID. Client is: %s . New authentication session tab ID: %s", userSessionId, client.getClientId(), authSession.getTabId());
187  } else {
188  rootAuthSession = manager.createAuthenticationSession(realm, true);
189  authSession = rootAuthSession.createAuthenticationSession(client);
190  logger.debugf("Sent request to authz endpoint. Created new root authentication session with ID '%s' . Client: %s . New authentication session tab ID: %s",
191  rootAuthSession.getId(), client.getClientId(), authSession.getTabId());
192  }
193  }
194 
195  session.getProvider(LoginFormsProvider.class).setAuthenticationSession(authSession);
196 
197  return authSession;
198 
199  }
KeycloakSession session
Definition: AuthorizationEndpointBase.java:69
static final Logger logger
Definition: AuthorizationEndpointBase.java:56
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

◆ createProcessor()

AuthenticationProcessor org.keycloak.protocol.AuthorizationEndpointBase.createProcessor ( AuthenticationSessionModel  authSession,
String  flowId,
String  flowPath 
)
inlineprotected
78  {
79  AuthenticationProcessor processor = new AuthenticationProcessor();
80  processor.setAuthenticationSession(authSession)
81  .setFlowPath(flowPath)
82  .setFlowId(flowId)
83  .setBrowserFlow(true)
84  .setConnection(clientConnection)
85  .setEventBuilder(event)
86  .setRealm(realm)
87  .setSession(session)
88  .setUriInfo(session.getContext().getUri())
89  .setRequest(httpRequest);
90 
91  authSession.setAuthNote(AuthenticationProcessor.CURRENT_FLOW_PATH, flowPath);
92 
93  return processor;
94  }
HttpRequest httpRequest
Definition: AuthorizationEndpointBase.java:67
ClientConnection clientConnection
Definition: AuthorizationEndpointBase.java:71
KeycloakSession session
Definition: AuthorizationEndpointBase.java:69
EventBuilder event
Definition: AuthorizationEndpointBase.java:61
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

◆ getAuthenticationFlow()

AuthenticationFlowModel org.keycloak.protocol.AuthorizationEndpointBase.getAuthenticationFlow ( AuthenticationSessionModel  authSession)
inlineprotected
148  {
149  return AuthenticationFlowResolver.resolveBrowserFlow(authSession);
150  }

◆ handleBrowserAuthenticationRequest()

Response org.keycloak.protocol.AuthorizationEndpointBase.handleBrowserAuthenticationRequest ( AuthenticationSessionModel  authSession,
LoginProtocol  protocol,
boolean  isPassive,
boolean  redirectToAuthentication 
)
inlineprotected

Common method to handle browser authentication request in protocols unified way.

引数
authSessionfor current request
protocolhandler for protocol used to initiate login
isPassiveset to true if login should be passive (without login screen shown)
redirectToAuthenticationif true redirect to flow url. If initial call to protocol is a POST, you probably want to do this. This is so we can disable the back button on browser
戻り値
response to be returned to the browser
105  {
106  AuthenticationFlowModel flow = getAuthenticationFlow(authSession);
107  String flowId = flow.getId();
108  AuthenticationProcessor processor = createProcessor(authSession, flowId, LoginActionsService.AUTHENTICATE_PATH);
109  event.detail(Details.CODE_ID, authSession.getParentSession().getId());
110  if (isPassive) {
111  // OIDC prompt == NONE or SAML 2 IsPassive flag
112  // This means that client is just checking if the user is already completely logged in.
113  // We cancel login if any authentication action or required action is required
114  try {
115  if (processor.authenticateOnly() == null) {
116  // processor.attachSession();
117  } else {
118  Response response = protocol.sendError(authSession, Error.PASSIVE_LOGIN_REQUIRED);
119  return response;
120  }
121 
122  AuthenticationManager.setClientScopesInSession(authSession);
123 
124  if (processor.nextRequiredAction() != null) {
125  Response response = protocol.sendError(authSession, Error.PASSIVE_INTERACTION_REQUIRED);
126  return response;
127  }
128 
129  // Attach session once no requiredActions or other things are required
130  processor.attachSession();
131  } catch (Exception e) {
132  return processor.handleBrowserException(e);
133  }
134  return processor.finishAuthentication(protocol);
135  } else {
136  try {
137  RestartLoginCookie.setRestartCookie(session, realm, clientConnection, session.getContext().getUri(), authSession);
138  if (redirectToAuthentication) {
139  return processor.redirectToFlow();
140  }
141  return processor.authenticate();
142  } catch (Exception e) {
143  return processor.handleBrowserException(e);
144  }
145  }
146  }
ClientConnection clientConnection
Definition: AuthorizationEndpointBase.java:71
AuthenticationFlowModel getAuthenticationFlow(AuthenticationSessionModel authSession)
Definition: AuthorizationEndpointBase.java:148
KeycloakSession session
Definition: AuthorizationEndpointBase.java:69
AuthenticationProcessor createProcessor(AuthenticationSessionModel authSession, String flowId, String flowPath)
Definition: AuthorizationEndpointBase.java:78
RealmModel realm
Definition: AuthorizationEndpointBase.java:60

メンバ詳解

◆ APP_INITIATED_FLOW

final String org.keycloak.protocol.AuthorizationEndpointBase.APP_INITIATED_FLOW = "APP_INITIATED_FLOW"
static

◆ authManager

AuthenticationManager org.keycloak.protocol.AuthorizationEndpointBase.authManager
protected

◆ clientConnection

ClientConnection org.keycloak.protocol.AuthorizationEndpointBase.clientConnection
protected

◆ event

EventBuilder org.keycloak.protocol.AuthorizationEndpointBase.event
protected

◆ headers

HttpHeaders org.keycloak.protocol.AuthorizationEndpointBase.headers
protected

◆ httpRequest

HttpRequest org.keycloak.protocol.AuthorizationEndpointBase.httpRequest
protected

◆ logger

final Logger org.keycloak.protocol.AuthorizationEndpointBase.logger = Logger.getLogger(AuthorizationEndpointBase.class)
staticprivate

◆ realm

RealmModel org.keycloak.protocol.AuthorizationEndpointBase.realm
protected

◆ session

KeycloakSession org.keycloak.protocol.AuthorizationEndpointBase.session
protected

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