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

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

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

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

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

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
Community showcase
Published in Jira Service Desk

The Complete Guide to Atlassian for ITSM

Hi Atlassian Community! This is Teresa from the Atlassian team. My colleague Paul Buffington @Buff and I are excited to share a brand new ITSM resource we’ve created – "The Complete Guide to At...

2,188 views 15 22
Read article

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