mitreid-connect
公開メンバ関数 | 静的公開変数類 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.openid.connect.web.EndSessionEndpoint クラス
org.mitre.openid.connect.web.EndSessionEndpoint 連携図
Collaboration graph

公開メンバ関数

String endSession (@RequestParam(value="id_token_hint", required=false) String idTokenHint, @RequestParam(value="post_logout_redirect_uri", required=false) String postLogoutRedirectUri, @RequestParam(value=STATE_KEY, required=false) String state, HttpServletRequest request, HttpServletResponse response, HttpSession session, Authentication auth, Model m)
 
String processLogout (@RequestParam(value="approve", required=false) String approved, HttpServletRequest request, HttpServletResponse response, HttpSession session, Authentication auth, Model m)
 

静的公開変数類

static final String URL = "endsession"
 

非公開変数類

SelfAssertionValidator validator
 
UserInfoService userInfoService
 
ClientDetailsEntityService clientService
 

静的非公開変数類

static final String CLIENT_KEY = "client"
 
static final String STATE_KEY = "state"
 
static final String REDIRECT_URI_KEY = "redirectUri"
 
static Logger logger = LoggerFactory.getLogger(EndSessionEndpoint.class)
 

詳解

Implementation of the End Session Endpoint from OIDC session management

著者
jricher

関数詳解

◆ endSession()

String org.mitre.openid.connect.web.EndSessionEndpoint.endSession ( @RequestParam(value="id_token_hint", required=false) String  idTokenHint,
@RequestParam(value="post_logout_redirect_uri", required=false) String  postLogoutRedirectUri,
@RequestParam(value=STATE_KEY, required=false) String  state,
HttpServletRequest  request,
HttpServletResponse  response,
HttpSession  session,
Authentication  auth,
Model  m 
)
inline
86  {
87 
88  // conditionally filled variables
89  JWTClaimsSet idTokenClaims = null; // pulled from the parsed and validated ID token
90  ClientDetailsEntity client = null; // pulled from ID token's audience field
91 
92  if (!Strings.isNullOrEmpty(postLogoutRedirectUri)) {
93  session.setAttribute(REDIRECT_URI_KEY, postLogoutRedirectUri);
94  }
95  if (!Strings.isNullOrEmpty(state)) {
96  session.setAttribute(STATE_KEY, state);
97  }
98 
99  // parse the ID token hint to see if it's valid
100  if (!Strings.isNullOrEmpty(idTokenHint)) {
101  try {
102  JWT idToken = JWTParser.parse(idTokenHint);
103 
104  if (validator.isValid(idToken)) {
105  // we issued this ID token, figure out who it's for
106  idTokenClaims = idToken.getJWTClaimsSet();
107 
108  String clientId = Iterables.getOnlyElement(idTokenClaims.getAudience());
109 
110  client = clientService.loadClientByClientId(clientId);
111 
112  // save a reference in the session for us to pick up later
113  //session.setAttribute("endSession_idTokenHint_claims", idTokenClaims);
114  session.setAttribute(CLIENT_KEY, client);
115  }
116  } catch (ParseException e) {
117  // it's not a valid ID token, ignore it
118  logger.debug("Invalid id token hint", e);
119  } catch (InvalidClientException e) {
120  // couldn't find the client, ignore it
121  logger.debug("Invalid client", e);
122  }
123  }
124 
125  // are we logged in or not?
126  if (auth == null || !request.isUserInRole("ROLE_USER")) {
127  // we're not logged in anyway, process the final redirect bits if needed
128  return processLogout(null, request, response, session, auth, m);
129  } else {
130  // we are logged in, need to prompt the user before we log out
131 
132  // see who the current user is
133  UserInfo ui = userInfoService.getByUsername(auth.getName());
134 
135  if (idTokenClaims != null) {
136  String subject = idTokenClaims.getSubject();
137  // see if the current user is the same as the one in the ID token
138  // TODO: should we do anything different in these cases?
139  if (!Strings.isNullOrEmpty(subject) && subject.equals(ui.getSub())) {
140  // it's the same user
141  } else {
142  // it's not the same user
143  }
144  }
145 
146  m.addAttribute("client", client);
147  m.addAttribute("idToken", idTokenClaims);
148 
149  // display the log out confirmation page
150  return "logoutConfirmation";
151  }
152  }
UserInfoService userInfoService
Definition: EndSessionEndpoint.java:74
static final String CLIENT_KEY
Definition: EndSessionEndpoint.java:64
SelfAssertionValidator validator
Definition: EndSessionEndpoint.java:71
ClientDetailsEntityService clientService
Definition: EndSessionEndpoint.java:77
String processLogout(@RequestParam(value="approve", required=false) String approved, HttpServletRequest request, HttpServletResponse response, HttpSession session, Authentication auth, Model m)
Definition: EndSessionEndpoint.java:155
static final String STATE_KEY
Definition: EndSessionEndpoint.java:65
static final String REDIRECT_URI_KEY
Definition: EndSessionEndpoint.java:66
ClientDetailsEntity loadClientByClientId(String clientId)
boolean isValid(JWT assertion)
Definition: SelfAssertionValidator.java:52
static Logger logger
Definition: EndSessionEndpoint.java:68

◆ processLogout()

String org.mitre.openid.connect.web.EndSessionEndpoint.processLogout ( @RequestParam(value="approve", required=false) String  approved,
HttpServletRequest  request,
HttpServletResponse  response,
HttpSession  session,
Authentication  auth,
Model  m 
)
inline
159  {
160 
161  String redirectUri = (String) session.getAttribute(REDIRECT_URI_KEY);
162  String state = (String) session.getAttribute(STATE_KEY);
163  ClientDetailsEntity client = (ClientDetailsEntity) session.getAttribute(CLIENT_KEY);
164 
165  if (!Strings.isNullOrEmpty(approved)) {
166  // use approved, perform the logout
167  if (auth != null){
168  new SecurityContextLogoutHandler().logout(request, response, auth);
169  }
170  SecurityContextHolder.getContext().setAuthentication(null);
171  // TODO: hook into other logout post-processing
172  }
173 
174  // if the user didn't approve, don't log out but hit the landing page anyway for redirect as needed
175 
176 
177 
178  // if we have a client AND the client has post-logout redirect URIs
179  // registered AND the URI given is in that list, then...
180  if (!Strings.isNullOrEmpty(redirectUri) &&
181  client != null && client.getPostLogoutRedirectUris() != null) {
182 
183  if (client.getPostLogoutRedirectUris().contains(redirectUri)) {
184  // TODO: future, add the redirect URI to the model for the display page for an interstitial
185  // m.addAttribute("redirectUri", postLogoutRedirectUri);
186 
187  UriComponents uri = UriComponentsBuilder.fromHttpUrl(redirectUri).queryParam("state", state).build();
188 
189  return "redirect:" + uri;
190  }
191  }
192 
193  // otherwise, return to a nice post-logout landing page
194  return "postLogout";
195  }
static final String CLIENT_KEY
Definition: EndSessionEndpoint.java:64
static final String STATE_KEY
Definition: EndSessionEndpoint.java:65
static final String REDIRECT_URI_KEY
Definition: EndSessionEndpoint.java:66

メンバ詳解

◆ CLIENT_KEY

final String org.mitre.openid.connect.web.EndSessionEndpoint.CLIENT_KEY = "client"
staticprivate

◆ clientService

ClientDetailsEntityService org.mitre.openid.connect.web.EndSessionEndpoint.clientService
private

◆ logger

Logger org.mitre.openid.connect.web.EndSessionEndpoint.logger = LoggerFactory.getLogger(EndSessionEndpoint.class)
staticprivate

◆ REDIRECT_URI_KEY

final String org.mitre.openid.connect.web.EndSessionEndpoint.REDIRECT_URI_KEY = "redirectUri"
staticprivate

◆ STATE_KEY

final String org.mitre.openid.connect.web.EndSessionEndpoint.STATE_KEY = "state"
staticprivate

◆ URL

final String org.mitre.openid.connect.web.EndSessionEndpoint.URL = "endsession"
static

◆ userInfoService

UserInfoService org.mitre.openid.connect.web.EndSessionEndpoint.userInfoService
private

◆ validator

SelfAssertionValidator org.mitre.openid.connect.web.EndSessionEndpoint.validator
private

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