It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Setting permission to use servlet plugin

Damian Józefiak May 18, 2014

Hi,

I'm writing JIRA Servlet Plugin Module and I wanted to set some kind of permission to use my servlet, for example only users from group jira-admin can use this plugin and if user is anonymous (s)he must log in, but I have no idea how to do this. I thougth about creating Java filter, but I'm not sure if this is good idea here. Is there any other way to do this?

1 answer

1 accepted

1 vote
Answer accepted

Hi,

In our company i have use this code in doGet methode to check if the user is logged

and you can check if the user is in jira-administrator group
if (jiraAuthenticationContext.getLoggedInUser()==null){
			String url = request.getContextPath()+"/login.jsp?permissionViolation=true&os_destination="+request.getRequestURI();
			StringBuffer stringBuffer = new StringBuffer();
			String fullUrl =(stringBuffer.append(url).append("?").append(request.getQueryString())).toString();
			response.sendRedirect(fullUrl);
		}

Damian Józefiak May 18, 2014

Works almost perfectly, but it looks like the path is broken, the path to my jira is https://hostname:port/jiraand i have repeated "/jira" in result of request.getRequestURI()
but I think I wil l handle it :) Thanks again :)

Hi,

Good luck.

Ankit Bhasin Oct 20, 2014

Hi, I got very similar requirement. But is it a good idea to hard-code the redirect URL (login.jsp). What if someone changes its login URL to use Single Sign On(SSO) or some other URL? Please have a look https://confluence.atlassian.com/display/JIRAKB/How+To+Change+JIRA+Login+and+Logout+URL

Geoff Wilson Aug 01, 2016

Did you ever write how to check if the user is in the jira-admin group? I don't see any code for that above

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in United States

Topic Tuesday: Agile

Another week, another Topic Tuesday!  Agile has been on my mind a lot lately because I've seen good implementations and bad implementations, but now as a Jira admin it matters more to me whether...

35 views 0 0
View post

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you