Github user bhaisaab commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/650#discussion_r36712694
--- Diff:
plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
---
@@ -322,21 +306,11 @@ public String authenticate(final String command,
final Map<String, Object[]> par
if (_apiServer.verifyUser(userAccount.getId())) {
LoginCmdResponse loginResponse =
(LoginCmdResponse) _apiServer.loginUser(session, userAccount.getUsername(),
userAccount.getUsername() + userAccount.getSource().toString(),
userAccount.getDomainId(), null,
remoteAddress, params);
- resp.addCookie(new Cookie("userid",
URLEncoder.encode(loginResponse.getUserId(), HttpUtils.UTF_8)));
- resp.addCookie(new Cookie("domainid",
URLEncoder.encode(loginResponse.getDomainId(), HttpUtils.UTF_8)));
- resp.addCookie(new Cookie("role",
URLEncoder.encode(loginResponse.getType(), HttpUtils.UTF_8)));
- resp.addCookie(new Cookie("username",
URLEncoder.encode(loginResponse.getUsername(), HttpUtils.UTF_8)));
- resp.addCookie(new Cookie("account",
URLEncoder.encode(loginResponse.getAccount(), HttpUtils.UTF_8)));
- String timezone = loginResponse.getTimeZone();
- if (timezone != null) {
- resp.addCookie(new Cookie("timezone",
URLEncoder.encode(timezone, HttpUtils.UTF_8)));
- }
- resp.addCookie(new Cookie("userfullname",
URLEncoder.encode(loginResponse.getFirstName() + " " +
loginResponse.getLastName(), HttpUtils.UTF_8).replace("+", "%20")));
- resp.addHeader("SET-COOKIE",
String.format("%s=%s;HttpOnly", ApiConstants.SESSIONKEY,
loginResponse.getSessionKey()));
+ SAMLUtils.setupSamlUserCookies(loginResponse,
resp);
resp.sendRedirect(SAML2AuthManager.SAMLCloudStackRedirectionUrl.value());
return
ApiResponseSerializer.toSerializedString(loginResponse, responseType);
}
- } catch (final CloudAuthenticationException ignored) {
+ } catch (final Exception ignored) {
--- End diff --
@jburwell @DaanHoogland catching pokemons allows to reduce redundant error
handling code, in case of any auth or IO exception (as the plugin is conversing
with the IDP server) an API authentication error is thrown at the bottom; not
sure what could be the best way of handling this without duplicating code
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---