<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Kerberos+with+REST+based+Services">Kerberos with REST based Services</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://docs.jboss.org/author/display/~rareddy">Ramesh Reddy</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>"Kerberos in ws-security with SOAP services"</b><br />Check out the cxf configuration to allow Kerberos in SOAP web services at <a href="http://cxf.apache.org/docs/security.html" class="external-link" rel="nofollow">http://cxf.apache.org/docs/security.html</a></td></tr></table></div>

<p>The kerberos support is based SPNEGO as described in <a href="http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-SpnegoAuthentication%28Kerberos%29" class="external-link" rel="nofollow">http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-SpnegoAuthentication%28Kerberos%29</a>. There two types of kerberos support</p>

<h3><a name="KerberoswithRESTbasedServices-NegotiationWiththisconfiguration%2CRESTserviceisconfiguredwithKerberosJAASdomain%2Ctonegotiateatoken%2Cthenuseitaccessthewebservice.Forthisfirstcreateasecuritydomaininstandalone.xmlfileasbelow"></a><b>Negotiation</b> - With this configuration, REST service is configured with Kerberos JAAS domain, to negotiate a token, then use it access the web service. For this first create a security domain in standalone.xml file as below</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;security-domain name="MY_REALM" cache-type="default"&gt;
     &lt;authentication&gt;
         &lt;login-module code="Kerberos" flag="required"&gt;
             &lt;module-option name="storeKey" value="true"/&gt;
             
             &lt;module-option name="useKeyTab" value="true"/&gt;
             &lt;module-option name="keyTab" value="/home/username/service.keytab"/&gt;
             &lt;module-option name="principal" value="host/testserver@MY_REALM"/&gt;

             &lt;module-option name="doNotPrompt" value="true"/&gt;
             &lt;module-option name="debug" value="false"/&gt;
         &lt;/login-module&gt;
     &lt;/authentication&gt;
&lt;/security-domain&gt; 
</pre>
</div></div>

<p>and the jboss-cxf-xxx.xml file needs to be set as</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;beans xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:sec="http://cxf.apache.org/configuration/security"  
        xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"  
        xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd"&gt;  
 
       &lt;http-conf:conduit name="*.http-conduit"&gt;
           &lt;http-conf:authorization&gt;
               &lt;sec:AuthorizationType&gt;Negotiate&lt;/sec:AuthorizationType&gt;
               &lt;sec:Authorization&gt;MY_REALM&lt;/sec:Authorization&gt;
           &lt;/http-conf:authorization&gt;
       &lt;/http-conf:conduit&gt;
&lt;/beans&gt;
</pre>
</div></div>

<p>The resource adapter creation needs to define the following properties</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
   &lt;config-property name="ConfigFile"&gt;path/to/jboss-cxf-xxxx.xml&lt;/config-property&gt;
   &lt;config-property name="ConfigName"&gt;test&lt;/config-property&gt;
</pre>
</div></div>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Even though above configuration configures the value of "ConfigName", the cxf framework currently in the case of JAX-RS client does not give option to use it. For that reason use "*.http-conduit" which will apply to all the HTTP communications under this resource adapter.</td></tr></table></div>

<h3><a name="KerberoswithRESTbasedServices-DelegationIfincasetheuserisalreadyloggedintoTeiidusingKerberosusingJDBC%2FODBCorusedSPNEGOinwebtierandusedpassthroughauthenticationintoTeiid%2CthenthereisnoneedtonegotiateanewtokenfortheKerberos...."></a><b>Delegation</b> - If in case the user is already logged into Teiid using Kerberos using JDBC/ODBC or used SPNEGO in web-tier and used pass-through authentication into Teiid, then there is no need to negotiate a new token for the Kerberos. The system can delegate the existing token.</h3>

<p>To configure for delegation, set up security domain defined exactly as defined in "negotiation", and jboss-cxf-xxx.xml file, however remove the following line from jboss-cxf-xxx.xml file, as it is not going to negotiate new token.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
  &lt;sec:Authorization&gt;MY_REALM&lt;/sec:Authorization&gt;
</pre>
</div></div>

<p>Add the following properties in web service resource adapter creation. One configures that "kerberos" security being used, the second defines a security domain to be used at the data source, in this case we want to use a security domain that passes through a logged in user</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
   &lt;config-property name="SecurityType"&gt;Kerberos&lt;/config-property&gt;
   &lt;security&gt;  
        &lt;security-domain&gt;passthrough-security&lt;/security-domain&gt;  
   &lt;/security&gt; 
</pre>
</div></div>

<p>To configure in "passthrough-security" security domain, the "security" subsystem add following XML fragment</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;security-domain name="passthrough-security" cache-type="default"&gt;  
    &lt;authentication&gt;  
        &lt;login-module code="org.teiid.jboss.PassthroughIdentityLoginModule" flag="required" module="org.jboss.teiid"&gt;  
            &lt;module-option name="username" value="guest"/&gt;  
            &lt;module-option name="password" value="guest"/&gt;  
        &lt;/login-module&gt;  
    &lt;/authentication&gt;  
&lt;/security-domain&gt;  
</pre>
</div></div>

<p>The username, password are optional, if in case there is no authenticated subject available in the context, these can help create a simple static user, but that user will not work with kerberos authentication as the subject will not have the kerberos token required.</p>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://docs.jboss.org/author/display/TEIID/Kerberos+with+REST+based+Services">View Online</a>
              |
       <a href="https://docs.jboss.org/author/display/TEIID/Kerberos+with+REST+based+Services?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>