# RootServices Lyo OAuth Web App

**URL:** <https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559>\
**Category:** Lyo\
**Created:** [November 26, 2021, 11:55am UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559 "2021-11-26T11:55:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael.C](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@Michael.C](https://forum.open-services.net/u/Michael.C)\
**Post date:** [November 26, 2021, 11:55am UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/1 "2021-11-26T11:55:06Z")

</div>

Hello, I m trying to implement a Jazz Root Services.

I’m using Lyo 4.0.0.  
I added in the web.xml :

```auto
<filter>

    <display-name>CredentialsFilter</display-name>

    <filter-name>CredentialsFilter</filter-name>

    <filter-class>com.sample.rm.servlet.CredentialsFilter</filter-class>

  </filter>

  <filter-mapping>

    <filter-name>CredentialsFilter</filter-name>

    <url-pattern>/services/*</url-pattern>

  </filter-mapping>
<servlet-mapping>

    <servlet-name>JAX-RS Servlet</servlet-name>

    <url-pattern>/services/*</url-pattern>

  </servlet-mapping>

  <servlet>

    <servlet-name>RootServicesService</servlet-name>

    <servlet-class>com.sample.rm.services.RootServicesService</servlet-class>

</servlet>

```

And I added

```auto
RESOURCE_SHAPE_PATH_TO_RESOURCE_CLASS_MAP.put(OslcConstants.PATH_OAUTH_CONFIGURATION, OAuthConfiguration.class);
        try
        {
        RESOURCE_CLASSES.add(Class.forName("org.eclipse.lyo.server.oauth.webapp.services.ConsumersService"));
        RESOURCE_CLASSES.add(Class.forName("org.eclipse.lyo.server.oauth.webapp.services.OAuthService"));
        } catch (ClassNotFoundException e)
        {
            e.printStackTrace();
            System.err.println("Application failed to initialize");
        }

```

In the Application.java

I also added the rootservices\_rdfxml.jsp file.

So far I can acces [http://localhost:8081/adaptor-rm/rootservices](http://localhost:8081/adaptor-rm/rootservices)  
I also can acces this directory [http://localhost:8081/adaptor-rm/oauth/](http://localhost:8081/adaptor-rm/oauth/) and the pages inside.

I took the adaptor-rm-webapp project as a base.

I can’t acces the REST endpoints :  
[http://localhost:8081/adaptor-rm/oauth/requestKey](http://localhost:8081/adaptor-rm/oauth/requestKey)  
[http://localhost:8081/adaptor-rm/oauth/approveKey](http://localhost:8081/adaptor-rm/oauth/approveKey)  
[http://localhost:8081/adaptor-rm/oauth/requestToken](http://localhost:8081/adaptor-rm/oauth/requestToken)  
[http://localhost:8081/adaptor-rm/oauth/authorize](http://localhost:8081/adaptor-rm/oauth/authorize)  
[http://localhost:8081/adaptor-rm/oauth/accessToken](http://localhost:8081/adaptor-rm/oauth/accessToken)

I got a 404 error.

Thanks for reading

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [November 26, 2021, 12:35pm UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/2 "2021-11-26T12:35:40Z")

</div>

Hello @Michael.C,

You should check in CredentialsFilter if the paths you are trying to access are protected or not. Those two you are talking about should be whitelisted. Example:

> <https://github.com/oslc-op/refimpl/blob/80c51d39e6bddf71ded8a701a02eca1b61c1a808/src/server-cm/src/main/java/co/oslc/refimpl/cm/gen/servlet/CredentialsFilter.java#L69>

As you can see, that code is designed for no-context deployment, where you don’t have the `adaptor-rm` context. I suggest you put some logging into the `isProtectedResource` method and tweak it if necessary.

@jad we may need to tweak this line to check for the context or strip it before the check: [generateCredentialsFilter.mtl#L109](https://github.com/eclipse/lyo.designer/blob/6ac16bf48e156c7ba17d97e2d8e0ca9e60d2c8c3/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateCredentialsFilter.mtl#L109)

Cheers,  
Andrew

---

<div class="post-metadata">

**Author:** ![Michael.C](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@Michael.C](https://forum.open-services.net/u/Michael.C)\
**Post date:** [November 26, 2021, 12:49pm UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/3 "2021-11-26T12:49:21Z")

</div>

Hello Andrew.

My filter is empty for now.

```auto
public class CredentialsFilter implements Filter {

    @Override

    public void destroy() {

    }

    @Override

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,

            FilterChain chain) throws IOException, ServletException {

                chain.doFilter(servletRequest, servletResponse);

}

    

    @Override

    public void init(FilterConfig arg0) throws ServletException {

        

    }

```

I did not find if it was possible to generate the rootService with Lyo designer. So I took the files from the adaptor-bugzilla.

---

<div class="post-metadata">

**Author:** ![Michael.C](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@Michael.C](https://forum.open-services.net/u/Michael.C)\
**Post date:** [November 26, 2021, 1:58pm UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/4 "2021-11-26T13:58:44Z")

</div>

I was accessing the wrong urls. They are like this [http://localhost:8081/adaptor-rm/services/oauth/requestKey](http://localhost:8081/adaptor-rm/services/oauth/requestKey)  
So I changed the content of rootservices\_rdfxml.jsp to reflect the correct urls but I don’t know how to change them in the imported jsp files from oauth-webapp

---

<div class="post-metadata">

**Author:** ![Michael.C](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@Michael.C](https://forum.open-services.net/u/Michael.C)\
**Post date:** [November 29, 2021, 1:23pm UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/5 "2021-11-29T13:23:54Z")

</div>

So your hint was helpfull. I modified the context with / and my urls are fine now.  
I also had to set an aplication and a consumer store for OAuthConfiguration.

I mostly return true for testing purpose.

I’m now able to link my serveur to Polarion, I also can see the list of services.

But when I click on “Select Work Item From Linked Data Friend Server” I got a popup with the following warning : “Friend server configuration is missing”.

Does anyone know what it means ?

---

<div class="post-metadata">

**Author:** ![Michael.C](https://forum.open-services.net/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@Michael.C](https://forum.open-services.net/u/Michael.C)\
**Post date:** [January 11, 2022, 10:23am UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/6 "2022-01-11T10:23:33Z")

</div>

I managed to solve my issues by having Polarion and the OSLC serveur on the same machine.

---

<div class="post-metadata">

**Author:** ![andrew](https://forum.open-services.net/user_avatar/forum.open-services.net/andrew/32/28_2.png) [@andrew](https://forum.open-services.net/u/andrew)\
**Post date:** [January 18, 2022, 9:26pm UTC](https://forum.open-services.net/t/rootservices-lyo-oauth-web-app/559/7 "2022-01-18T21:26:08Z")

</div>

If having both apps on the same machine helps, you should look at [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src)/CORS settings that prevent website data to be stolen by hackers but may make integration work harder. Polarion also had problems with overly restrictive use of [SameSite=Strict](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) cookie attribute, preventing it from being sent when a Polarion page is loaded in an iframe, even after you type your login and password.
