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())
> 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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.