Is user id unique across different installation?

imamudin naseem April 4, 2018

I am developing a plugin for JIRA cloud, and have to get unique id for the user across installations. 

JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser loggedInUser = authContext.getLoggedInUser();
loggerInUser.getId(); //10000

For me loggerInUser.getId() returns 10000. So can there be a case where it returns the same id(i.e 10000) for different user in a different team, different project ??

If yes, what is the best way to uniquely identify a user? 

4 answers

0 votes
minaseem April 5, 2018

Thanks a lot @Nic Brough -Adaptavist- for the help

0 votes
minaseem April 4, 2018

So, you are that I should not worry about creating unique key. I can just use ACCESS_TOKEN_{jiraUser.getId()} as key since for other user with same id it will be separate instance, separate environment. So it is not gonna collide. Right?

0 votes
minaseem April 4, 2018

I am writing a plugin which appears as web panel in right bar of issue page. First of all user will be doing oauth will some third party app. Then I am storing access tokens(which came via oauth) using PluginSettingsFactory, which stores data in key-value format. I want to store access tokens with some unique key like ACCESS_TOKEN_{UserId} which I am struggling to create. 

Once oauth is done, I would be asking user for select some configuration which will come as form on issue page's right bar.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 4, 2018

You don't need some form of botched incorrect uniqueness for that, you don't actually care where else the account has been used, and you're not vulnerable to attack because it's a separate application.

I don't understand what you think you need here.

imamudin naseem April 4, 2018

So, you are saying that I should not worry about creating unique key. I can just use ACCESS_TOKEN_{jiraUser.getId()} as key since for other user with same id it will be separate instance, separate environment. So it is not gonna collide. Right?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 5, 2018

Correct, it's not needed because they're separate.

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2018

The id is unique across teams and projects. It is unique within a JIRA installation but you might find the same id if you are querying a different instance of JIRA.

imamudin naseem April 4, 2018

@Jobin Kuruvilla [Adaptavist] Thanks for answering.

what do you mean by "a different instance of JIRA"?

Do two JIRA installations on JIRA Cloud mean two instances?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 4, 2018

There are hundreds of thousands of different, separate servers out there running Jira instances.  On some of them, I log in as nbrough.  In a couple of them, that will be user 10000.  In most of them, it won't be, I will have a different ID for my account.

Cloud is slightly different - it uses Atlassian accounts.  My Atlassian account lets me access around 30 of them.  Although I am only using one Atlassian account, the ID you'll find for it will vary across all of them

So, yes, "two Cloud installations are two instances", and "no, you cannot assume that user 10000 on instance 1 is the same account as 10000 on instance 2".  You will need to be looking at the whole account, matching it on the Atlassian ID (email is probably the best proxy for that)

imamudin naseem April 4, 2018

@Nic Brough -Adaptavist- Thanks for the clarity. 

With email too, we'll not be able to uniquely identify a user. user might be registered to two instances with same email. 

I need to create an identifier for user across instances. 

If some how I can get instance id, instanceid.concat(userId) can be used as indentifier. I am not sure if there is a way to get instance id.

Please let me know if you have some way of creating an identifier for user across instances. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 4, 2018

I don't understand your comment about email.  If a user is registered on two different Jira instances with the same email, then they should be the same person, and hence unique.  In fact, that's what Atlassian IDs do on cloud - you can only have one Atlassian account for an email address, and many Cloud systems use that one unique account.  They'll have different IDs in the system, but the email is for one single unique user.

imamudin naseem April 4, 2018

For me a user(with single email) on two instances are two different users.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 4, 2018

Well, they're almost always going to be the same human (and absolutely should be the same user)

I think this takes us back to the actual requirement through.  What are you actually trying to achieve and why?  What use is it?  What problem are you trying to solve?

Suggest an answer

Log in or Sign up to answer