Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an existing API available in JIRA to find out if a user is already logged in

Subhajit Bhuiya June 30, 2018

From a JIRA plugin, I want to know if a particular user is logged in. Is there an API available for it?

Also is there a list of API available to find out list of currently logged in users.

2 answers

0 votes
Nic Brough -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.
July 1, 2018

"user is logged in" is the wrong way to think about how user access works with services.  When a user "logs in" with a shell or runs a program on a machine, there is a process that runs and you can point at that process and say "they are logged in".

With web applications such as Jira, you can not.  A user requests that the service do something (show me a page, update an issue, etc) and the service does it.  If there are "logins" and "user accounts", then the service will require credentials of some form so it can work out how to do it for the user (including if it is possible).  The usual way to do this is to ask the user to "log in" and then create and store some "session" stuff, which may or may not expire, and are partially held on the client machine and the server.

But the sessions are not "logins".  The user is only truly "logged in" for fractions of a second while they are actively getting the service to do something.

Sessions are not the same as being logged in.  I have a Jira that I can visit now that I will go straight into with no "log in" because I was using it an hour ago.  At the moment, there is no sign of me being "logged in" because I have no browser windows open with it, or REST scripts talking to it.  But I do have a session open with it.  I could also go to another machine, and open another session with it there. 

You need to start with a think about what you really mean by "logged in".  In my example above, would I be "logged in" twice with those two machines?  When I have no browser windows open, am I "logged in"? 

0 votes
Mark Markov
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.
June 30, 2018

Hello @Subhajit Bhuiya

Yes, there are API for that.

Please check 

https://docs.atlassian.com/software/jira/docs/api/7.0.6/com/atlassian/jira/security/JiraAuthenticationContext.html

So in plugin you need inject it via @ComponentImport

Subhajit Bhuiya June 30, 2018

@Mark Markov It gives the current logged in user in the context. What I am looking is given a user id, JIRA to tell me if the user is currently logged in or may be an API which will give the list of users who are currently logged in

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events