How to custom 401 unauthorized response from jira plugin rest api

Nhac Tat Nguyen December 11, 2018

I have a REST API inside my jira plugin, without @AnonymousAllowed annotation:

Code resource.PNG

My question is: How can I custom 401 response when an unauthorized user try to access my resources, such as redirect them to another page, or send them a HTML page,... instead of just send a xml error. Thanks a lot for your help.

message.PNG

1 answer

1 accepted

2 votes
Answer accepted
Alexey Matveev
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.
December 12, 2018

Hello,

You should add the serlvet-filter module:

https://developer.atlassian.com/server/jira/platform/servlet-filter/

You should catch all request to the 401 error page and redirect your user to the page you want.

Nhac Tat Nguyen December 12, 2018

Thanks Alex, it helps me.

Alexey Matveev
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.
December 12, 2018

You are most welcome!

Suggest an answer

Log in or Sign up to answer