I have enabled hawtio security on wildfly by adding the following in standalone.xml:
<system-properties>
<property name="hawtio.authenticationEnabled" value="true" />
<property name="hawtio.realm" value="jboss-web-policy" />
<property name="hawtio.role" value="admin,viewer" />
</system-properties>
and then created an application user using add-user.sh and i am able to successfully login using the credentials i added for that user.
Now, I want that only data specific to that user should be visible on my plug ins and for that i need user details of the current authenticated user, but i am not able to find any suitable example implementing this. What should be the best approach to go ahead with this?
There are two ways to get the login user from your Hawtio plugin.
Inject userDetails
into the AngularJS controller for your plugin. userDetails.username
will return the name of the login user. See this example:
https://github.com/hawtio/hawtio/blob/hawtio-1.5.10/hawtio-web/src/main/webapp/app/activemq/js/preferences.ts#L7
Access the servlet endpoint http://localhost:8080/hawtio/user, which returns the name of the login user as string.
Either way is ok but the option 1 would be the first choice. The option 2 can be used when it is required out of the normal AngularJS app lifecycle such as being across page reload.