Hi,
I believe that the default JIRA macros make use of the current session user to perform queries and link Confluence to JIRA (is this true?)
I am developing a Confluence Space that on a specific page I need to do a few API calls to return information (I use the HTML macro to do this)
Currently I have a dummy user that I use as the user to make the queries (it has a jira-software-user license slot). This user is used regardless of the user viewing the page.
What I need to do is use the current session user's login and password (they are the same for JIRA and Service Desk so any API call to JIRA made on Confluence will work this way) for the query (currently I pass them on the query string by variable, it is enough and secure since our JIRA instance is not open to the world.
How can I get access to the Users login and password on a Page level? Is it on a variable accessible at the page? If I need to use a macro to get this, how can I do it?
Thanks !
Hello there!
Interesting project you have there Gualter. As I understand, you need to access the current user credentials for this to work, correct?
We can do that by creating a user macro with Velocity. Here I have an example for you Gualter:
## @noparams
$action.authenticatedUser.name
$action.authenticatedUser.fullName
$action.authenticatedUser.key
$action.dateFormatter.formatGivenString("yyyy-MM-dd", $content.getCreationDate())
For anyone else reading this thread, keep in mind that User Macros Are Only Available For Confluence Server. Confluence cloud does not have this functionality. You can check a little more about it here:
Atlassian Cloud vs. server: features and use cases
Atlassian cloud vs server apps
Moving forward. The object we call there $action.authenticatedUser will allow us to access some information about the current user in the page. Here you can check a little more on which objects are accessible:
Confluence objects accessible from Velocity
Let me know if that helps you out Gualter! Looking forward to your reply.
Hello,
Thank you for your answer. I will explore this.
A bit of context:
I am creating a Confluence Space that will be the bridge for our Non tech teams to search issues, create new ones, and have a general overview of their reported issues, both in JIRA and JIRA SD.
It will also query JIRA to get issues count and details so it can generate charts (chart.js) and tables that will look more neat than the current JIRA UI.
I was able to create a macro to get the session username using:
## @noparams
#set($userDetailsManager = $containerContext.getComponent('userDetailsManager'))
#set( $user = $action.remoteUser)
$user.email
This will print out the current user session so I can get half of it done. I am only missing the password field. However with the username I can have a dummy bot user to generate all my issues and API requests and then assign the reporter to the username I get above.
Cheers !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the update Gualter!
As far as I understand, we can not really grab the user password via velocity. Nonetheless, good to know that we could help get you started Gualter.
Let us know from you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed you cannot.
I used to current user approach to assign the session user as the reporter on the issue in JIRA. To create the issue I use a bot user that makes API calls.
Thank you for the help !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.