Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

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 Leaders.
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 ?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events