Setting permission to use servlet plugin

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);
		}

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, 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

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
Community showcase
Published 13 hours ago in Agile

Managing Projects in Several Jiras at the Same Time

Have you ever noticed that fixing specific problems might be a door opener for a bigger challenge, affecting a wider audience? This was exactly the case when we, as a service company working with mul...

61 views 0 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you