The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

While calling Rest end point (BaseScript CustomEndpointDelegate) from ScriptRunner getting 403 error

Prasad Pendke
May 7, 2019

I am calling Rest end point (Base Script Custom End point Delegate) using httpbuilder ,

I am getting 403 error .  

Base Script Custom Endpoint Delegate 

delegate doSomething ( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> return Response.ok(new JsonBuilder([abc: 42]).toString()).build() }
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method

def httpBuilder = new HTTPBuilder(urlOfYourDataSource)
def responseData
httpBuilder.request(Method.GET, ContentType.JSON) {
response.success = {resp, data ->
responseData = data
}
response.failure = {resp, text ->
log.error "Error: $text"
}
}

 

If we want to add basic auth in header ,

from where can I get user name and password at run-time for individual user 

 

httpRequest.addHeader('Authorization', 'Basic ' + 'username:password'.bytes.encodeBase64().toString())

 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
JamieA
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 Champions.
May 8, 2019

> from where can I get user name and password at run-time for individual user 

You can't get that, and you don't need it... you should not try to write an integration by calling a local rest api from the server... just do whatever you need to do using the java api.

Prasad Pendke
May 8, 2019

I wanted to secure the REST END POINT written in Jira .

That's why I have mentioned groups to restrict to user having given roles .

ase Script Custom Endpoint Delegate 

delegate doSomething ( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> return Response.ok(new JsonBuilder([abc: 42]).toString()).build() }

 

I have not able to pass basic auth using http builder that's why I am getting 403 error . 

 

Is  there any other way to secure rest end point ?

TAGS
AUG Leaders

Atlassian Community Events