Login via Rest

14 views
Skip to first unread message

Dominik Spies

unread,
Jun 8, 2020, 10:02:02 AM6/8/20
to webanno-user
Hello,
I'm trying to add a REST API to Webanno.
So far I've managed to add a rest service by mounting a Wicketstuff AbstractRestResource in the WicketApplicationBase. This also works as long as the user is already logged in. My problem is now, that I also want to be able to authenticate a user via the rest service. But every rest request I'm trying automatically gets redirected to the web anno login page. 
Could you tell me, where I can disable this automated redirection?

Thank you and best regards
- Dominik

Jan-Christoph Klie

unread,
Jun 8, 2020, 10:21:30 AM6/8/20
to webanno-user
Hello Dominik,
Webanno already has a REST API [1] and even a Python client for it [2]. Is there something missing that you need? If yes, then you can have a look how it is implemented [3] to maybe solve your issue.

Best,

Jan

Dominik Spies

unread,
Jun 9, 2020, 6:20:20 AM6/9/20
to webanno-user
Hello Jan,

Thank you for your response.
I didn't know Webanno had a REST API. From what I can see most things I need are present. I assume that most editing operations are by deleting the old version and adding a new one, since there seem to be no update interfaces. Or does it mean, that editing annotations or projects via the REST API is not intended?

Thnaks again
- Dominik

Richard Eckart de Castilho

unread,
Jun 9, 2020, 6:25:12 AM6/9/20
to Dominik Spies, webanno-user
Hi,

> On 9. Jun 2020, at 12:20, Dominik Spies <domini...@qualicen.de> wrote:
>
> I didn't know Webanno had a REST API. From what I can see most things I need are present. I assume that most editing operations are by deleting the old version and adding a new one, since there seem to be no update interfaces. Or does it mean, that editing annotations or projects via the REST API is not intended?

The AERO protocol is designed allow integrating the annotation tool into a larger workflow and e.g. supports uploading and downloading of entire annotated documents and projects. It is not meant to make small-scale changes such as editing individual annotations. E.g. it is not well-suited for implementing an annotation editor plugin on top of it.

-- Richard

Dominik Spies

unread,
Jun 9, 2020, 6:38:00 AM6/9/20
to webanno-user
Hi, 

Thanks for the response.
Sadly this was the thing I'd need for my use-case.  In this case I'd either have to edit the existing API or create one that is suited for small scale edits.
Could you give me some pointers, on what would be necessary for creating an additional API. As I've said in my first post I ran into the problem, that my requests got redirected to the login page. I assume there is some point in the code, where an exception for this redirection is added for the purpose of the AERO API.
Best Regards
- Dominik

Richard Eckart de Castilho

unread,
Jun 9, 2020, 6:51:29 AM6/9/20
to Dominik Spies, webanno-user
Hi,

> On 9. Jun 2020, at 12:38, Dominik Spies <domini...@qualicen.de> wrote:
>
> Could you give me some pointers, on what would be necessary for creating an additional API. As I've said in my first post I ran into the problem, that my requests got redirected to the login page. I assume there is some point in the code, where an exception for this redirection is added for the purpose of the AERO API.

Normally, you would add a new editor by extending the AnnotationEditorBase. In the editors that we use so far, when then use an AbstractDefaultAjaxBehavior to establish communication with the client-side JavaScript.

If you wanted to implement an annotation interface which completely hides the backend and only communicate with it via some REST API, you'd probably want to implement another Spring REST service similar to the AeroRemoteApiController which would provide finer-grained access. The new REST controller must also be configured with Spring Security so it can use e.g. HTTP basic authentication instead of form-based authentication.

If you do that, the recent changes to the CAS storage (CasStorageSession) will likely become crucial for you - i.e. that CAS objects can now be kept in memory and can be accessed via a pool which ensures that multiple concurrent threads cannot make simultaneous modifications. This is currently only available on the INCEpTION/WebAnno master branches.

We had done some work towards an annotation-oriented REST API in INCEpTION a while back, but didn't yet find the time to get back to it. The latest status is here:

https://github.com/inception-project/inception/blob/feature/700-Support-for-custom-annotation-UIs/inception-annotation-mvc/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/RemoteApiControllerRuita.java

This API is the output of a student project and - as I said - we didn't yet find the time to get back to it. One of the reasons was that the above mentioned CAS caching in memory was not there until a like 2 weeks ago.

Cheers,

-- Richard

Richard Eckart de Castilho

unread,
Jun 9, 2020, 6:55:42 AM6/9/20
to Dominik Spies, webanno-user
On 9. Jun 2020, at 12:51, Richard Eckart de Castilho <richard...@gmail.com> wrote:
>
> We had done some work towards an annotation-oriented REST API in INCEpTION a while back, but didn't yet find the time to get back to it. The latest status is here:
>
> https://github.com/inception-project/inception/blob/feature/700-Support-for-custom-annotation-UIs/inception-annotation-mvc/src/main/java/de/tudarmstadt/ukp/clarin/webanno/webapp/remoteapi/RemoteApiControllerRuita.java

I'm also pretty sure that this code accesses the annotations directly from the CAS and not via the usual rendering methods - meaning that information injected through editor extensions (e.g. recommendations in INCEpTION) wouldn't appear. This particular code is over 2 years old by now. When working on this subject again today, it would probably be done quite differently.

-- Richard
Reply all
Reply to author
Forward
0 new messages