<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How to secure Rest Services from Ivy 6.2 with Authorization Bearer instead of Basic</title><link>https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic</link><description>&lt;p&gt;As the tittle. I'm using Ivy version 6.2 and would like to know how to secure my REST Services using Bearer Authorization instead of basic.
Thanks&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 28 Jun 2018 02:55:25 -0400</lastBuildDate><item><title>Answer by thminh</title><link>https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic/3345</link><description>&lt;p&gt;Thanks for your instructions. I created a custom valve in Ivy 7.1 to validate the bearer token. Inside the method, I get the Authorization token in the header and check if it is valid or not, if not, could I stop the request and throw an unauthorized exception back to the client?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

    String token = request.getHeader("Authorization");

    if(StringUtils.isEmpty(token)){
        getNext().invoke(request, response);
        return;
    }
    if(TokenValidator.isValidToken(token)){
        String userName = extractUserNameFromToken(token);
        request.setUserPrincipal(createUserPrincipal(userName));
        getNext().invoke(request, response);
    } else {
        // How to reject the request and throw unauthorized exception back to the client? 
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">thminh</dc:creator><pubDate>Thu, 28 Jun 2018 02:55:25 -0400</pubDate><guid>https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic/3345</guid></item><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic/3341</link><description>&lt;p&gt;You are free to use any authentication method on modern Axon.ivy platforms.&lt;/p&gt;
&lt;p&gt;If you need a non standard authorization approach just implement a custom tomcat valve for authentication and authorization: &lt;a href="https://developer.axonivy.com/doc/latest/EngineGuideHtml/integration.html#integration-waf-sso"&gt;https://developer.axonivy.com/doc/latest/EngineGuideHtml/integration.html#integration-waf-sso&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Implementation details can be found here: &lt;a href="https://developer.axonivy.com/doc/latest/EngineGuideHtml/configuration.html#configuration-tomcat-context-xml"&gt;https://developer.axonivy.com/doc/latest/EngineGuideHtml/configuration.html#configuration-tomcat-context-xml&lt;/a&gt;
or here
&lt;a href="https://github.com/ivy-samples/tomcatValve"&gt;https://github.com/ivy-samples/tomcatValve&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;... so far about modern Platforms. But I'm not sure whether this works on the very outdated 6.2 leading edge version.&lt;/strong&gt;
So I suggest that you basically ensure that it works on 7.0 LTS. And may give it a try afterwards in the old 6.2...
Keep in mind: it was never the idea that outdated leading edge versions are used productive for a long time. Update as fast as you can if you want to operate a secure engine with well documented supported featureset. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Fri, 22 Jun 2018 02:25:22 -0400</pubDate><guid>https://answers.axonivy.com/questions/3338/how-to-secure-rest-services-from-ivy-6-2-with-authorization-bearer-instead-of-basic/3341</guid></item></channel></rss>