Can't retrieve user roles

2019-07-09 10:39发布

I am trying to return a list of roles back to a mobile client device from the WL server

In the createIdentity method of my LoginModule I added the following code

HashMap<String, Object> customAttributes = new HashMap<String, Object>();
customAttributes.put("AuthenticationDate", new Date());

Set<String> groups = new HashSet<String>();
groups.add("Managers");
groups.add("Users");

UserIdentity identity = new UserIdentity(loginModule, USERNAME, "Fred Flintstone", groups, customAttributes, PASSWORD);

The display Name "Fred Flintstone" gets returned to the mobile device, the custom attributes get returned, but the group information seems to get lost somewhere.

I get the following displayed in the mobile device logs

"BasicAuthRealm":{"userId":"user1","attributes":{"AuthenticationDate":"Thu Nov 14 22:39:35 EST 2013"},"isUserAuthenticated":1,"displayName":"Fred Flintstone"},"WL-Authentication-Success":{"BasicAuthRealm":{"userId":"user1","attributes":{"AuthenticationDate":"Thu Nov 14 22:39:35 EST 2013"},"isUserAuthenticated":1,"displayName":"Fred Flintstone"}},

I am running WL 6.0.0.1 Enterprise edition and running against a Liberty server v8.5.5.0

Any ideas?

1条回答
叼着烟拽天下
2楼-- · 2019-07-09 11:16

The groups object is not sent back to the client after the user successfully authenticates. The only parts of the UserIdentity object that are sent back are the name, displayName, and the attributes. I do not know the reason that the groups aren't sent back. Perhaps the objects purpose was only meant for the server and was never intended to be used by the client.

The unfortunate but easy workaround is to add any information you need to know about your group to your attributes object.

查看更多
登录 后发表回答