Hi Bradley Barber,

You need to use httpclient to support setting up the 
session(org.apache.httpcomponents:httpclient:4.5.3).
Log in to zeppelin's login, get the ticket, set it to the http session, Then 
you can do other operations.

You can also use the following steps to verify and experiment with curl.
The first step is to authentic through the API with a POST to /api/login

curl -i --data 'userName=admin&password=password1' -X POST 
http://127.0.0.1:9995/api/login
This should return a response like the following:

HTTP/1.1 200 OK
Date: Wed, 17 Aug 2016 10:07:22 GMT
Access-Control-Allow-Origin:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: authorization,Content-Type
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, HEAD, DELETE
Date: Wednesday, August 17, 2016 10:07:22 AM UTC
Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Tue, 16-Aug-2016 
10:07:22 GMT
Set-Cookie: JSESSIONID=b1f15e00-4571-4079-a699-338bf619b0c4; Path=/; HttpOnly
Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Tue, 16-Aug-2016 
10:07:22 GMT
Content-Type: application/json
Date: Wed, 17 Aug 2016 10:07:22 GMT
Content-Length: 118
Server: Jetty(9.2.15.v20160210)

{"status":"OK","message":"","body":{"principal":"admin","ticket":"47a1fe3a-593d-47ce-85bb-f6e7238c6dcb","roles":"[]"}}
The important thing to see here is the Set-Cookie in the response headers.

Look for the following:

Set-Cookie: JSESSIONID=b1f15e00-4571-4079-a699-338bf619b0c4; Path=/; HttpOnly
Using this cookie we can make authorized request to the API by simply setting 
this as a cookie in the cURL request.

curl -i -b 'JSESSIONID=b1f15e00-4571-4079-a699-338bf619b0c4; Path=/; HttpOnly' 
http://127.0.0.1:9995/api/notebook
This request should now return a 200 OK response after adding the JSESSIONID 
cookie.

HTTP/1.1 200 OK
Date: Wed, 17 Aug 2016 10:10:44 GMT
Access-Control-Allow-Origin:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: authorization,Content-Type
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, HEAD, DELETE
Date: Wednesday, August 17, 2016 10:10:44 AM UTC
Content-Type: application/json
Date: Wed, 17 Aug 2016 10:10:44 GMT
Content-Length: 1012


> 在 2018年12月1日,上午1:34,Bradley Barber <bbar...@phemi.com> 写道:
> 
> Hi all,
> 
> I'm noticing when I log into Zeppelin (0.8) via the REST api, although a 
> Zeppelin Ticket is returned in the response, the Ticket value is not 
> accessible within my Notebook via 
> z.getInterpreterContext.getAuthenticationInfo.getTicket. It is accessible via 
> this call when logging in with the GUI, however. My question is: is there a 
> way to have the Ticket value set in the AuthinticationInfo object when 
> logging in via REST? I am using authc authentication with shiro btw, in case 
> that is relevant.
> 
> Thanks, 
> Bradley  

Reply via email to