How to password protect REST web services

Solution Unverified - Updated -

Environment

  • Red Hat JBoss Fuse
    • 6.2.0

Issue

  • We have successfully pushed our web service to HTTPS but now we want web service to be protected by username and password for each client.
  • We have REST Webservice created using Blueprint. It consumes JSON input and produces JSON output. We want to expose this REST service to 3rd party clients but we want to limit access to REST web service to authorized clients only.
  • Which is recommended way by Redhat team to secure REST web service in JBOss FUse 6.1 vesrion. We are using Fabric environment.

Resolution

  • There is an example provided for Securing REST based services at location(Within Fuse installation):
jboss-fuse-6.1.0.redhat-379/quickstarts/secure-rest
  • You can use this example to implement authentication. Implementation is like
<jaxrs:server id="customerService" address="/securecrm">
        ---
        <jaxrs:providers>
            <ref component-id="authenticationFilter"/>
        </jaxrs:providers> 
    </jaxrs:server>

<bean id="authenticationFilter" class="org.apache.cxf.jaxrs.security.JAASAuthenticationFilter">
        <!-- Name of the JAAS Context -->
        <property name="contextName" value="karaf"/>
</bean>
  • More details can be found at README.md file provided with example.
  • If user want to have a unique username/password for his webservice, using interceptors this is possible.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.