Skip to content
Snippets Groups Projects

feature: Add uw-frame compatible REST API for /profile

Merged Nicholas Blair requested to merge npblair/uw-spring-security:alternate-profiles into master

This pull request adds a REST resource under /profile that transforms the current UWUserDetails into a format matching uw-frame's session.json feed.

With this feature in place, uw-frame apps will be able to have the user attributes from the UW Spring Security principal display in the frame header.

Here's the familiar Amy Administrator, as output from GET /profile/uw-frame:

{
  username: "admin",
  displayName: "Amy Administrator",
  firstName: "Amy",
  lastName: "Administrator",
  serverName: "",
  version: "",
  sessionKey: ""
}

To configure this feature in a uw-frame app, one needs to create a file named src/main/webapp/js/override.js (if not already present) with the following contents:

define(['angular'], function(angular) {
    var config = angular.module('override', []);
    config
        .constant('OVERRIDE', {
            'SERVICE_LOC': {
                'sessionInfo' : 'profile/uw-frame',
            }
        })
    ;
    return config;
});

Notify @andrew-petro @levett @ahoffmann @paul.erickson @bjsousa @andrew-summers @alundholm

To assignee @dwitter2 - the plan is to use this for capital-equipment and iaa-diagnostic-tool, among others, then we no longer have the mismatch in our demos (with frame defaulting to showing one logged in as 'Bucky').

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
40 40 *
41 41 * The format of the properties is as follows (key=value):
42 42 * <pre>
43 * username=password,fullName,emailAddress[,membership1,[membership2...]]
43 * username=password,fullName,firstName,lastName,emailAddress[,membership1,[membership2...]]
44 44 * </pre>
45 45 *
46 46 * Membership can be 1 or more UDDS values, comma separated.
47 47 */
48 48 @Override
49 49 public UWUserDetails mapUser(String username, String[] values) {
50 if(values.length > 4) {
51 String[] uddsValues = Arrays.copyOfRange(values, 4, values.length);
50 if(values.length > 6) {
  • Oofdah, this is quite a breaking change. Is there any way we can warn existing consumers of this class that this happened? An exception if it finds fewer than 6 values?

    Can I submit a JIRA somewhere to suggest switching to YAML or JSON format for local users instead of clunky properties files?

  • Yep, that's why this PR includes a version bump. If you aren't overriding the default LocalUserDetailsAttributesMapper, you'll need to do nothing. If you are already overriding the default LocalUserDetailsAttributesMapper, this change won't affect you, because you are already overriding it :).

    :thumbsup: on the feature suggestion; we don't have a JIRA, and they've disabled issues in gitlab for some reason.

    https://git.doit.wisc.edu/adi-ia/uw-spring-security/issues FTW!

    Edited by Nicholas Blair
  • :police_car: Breaking change! :police_car: I just verified that this breaks the build in STAR, so it should be a major version bump to 2.0.0 (minor version indicates that 1.x consumers can safely upgrade without changes).

  • @paul.erickson can you open an issue? I just took a gander in star, and it looks like you may be right - star-app has a copy of demo-users.properties, missing the firstName and lastName.

    We could issue a patch fix to 1.2 that provides backwards compatibility for values.length == 4 || values.length == 5, along with a LOG.warn.

  • Good thinking, I just created #1 (closed)

  • 1 /**
    2 *
    3 */
    4 package edu.wisc.uwss.web.uwframe;
    5
    6 import org.apache.commons.lang.StringUtils;
    7
    8 /**
    9 * Bean that mimics the data model uw-frame expects for the application's build information.
    10 *
    11 * @author Nicholas Blair
    12 */
    13 public class UwframeBuild {
    • How is build information related to the new session REST endpoint? Did this sneak into this PR?

    • It's technically part of uw-frame's data model for a "session". Here's an example (go to https://my.wisc.edu/portal/web/session.json):

      {
        person: {
          lastName: "Blair",
          userName: "npblair",
          sessionKey: "something",
          serverName: "something",
          firstName: "Nicholas",
          displayName: "Nicholas Blair",
          version: "4.2.1.4"
        }
      }
    • Since uw-frame depends on uw-spring-security and not the other way around, wouldn't it be more appropriate to say that "uw-frame consumes the class UwSpringSecurityBuild (or just 'Build', e.g.)" than "uw-spring-security implements "UwframeBuild"?

    • I missed that, thanks!

    • There is no dependency relationship between the 2 projects; uw-frame doesn't depend on this, nor does this depend on uw-frame.

      This bean is merely a local representation of a JSON API presented by MUM's /portal (which is actually uPortal).

  • This is great! UW Spring Security is coming along very nicely.

  • Please register or sign in to reply
    Loading