cancel
Showing results for 
Search instead for 
Did you mean: 

Change HTTP Basic Authentication realm

fast3r
Champ on-the-rise
Champ on-the-rise
Hi everybody, I'm using Alfresco Labs 3 Stable.

When I access to a RSS feed content in Share (ex. for the webscript doclist.get.rss), I get these HTTP headers, related to the HTTP Basic Auth login:

HTTP/1.x 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-Authenticate: Basic realm="Alfresco"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: …


How can I change the realm value "Alfresco"? Where is the configuration file for Basic HTTP Authentication?
I've found the LDAP and JAAS ones, but I don't think they're what I'm looking for.

Thank you very much in advance…
4 REPLIES 4

steffen
Champ in-the-making
Champ in-the-making
looks like the realm is hard-coded in the org.alfresco.web.scripts.BasicHttpAuthenticatorFactory:


            // request credentials if not authorized
            if (!authorized)
            {
                if (logger.isDebugEnabled())
                    logger.debug("Requesting authorization credentials");
               
                res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
                res.setHeader("WWW-Authenticate", "Basic realm=\"Alfresco\"");
            }

you could define a new impelementaion of the "webscripts.authenticator.delegatingbasic" bean in the web-framework-config-custom.xml.

HTH

steffen

fast3r
Champ on-the-rise
Champ on-the-rise
Thanks a lot!
I had found it in several classes but not this one!

you could define a new impelementaion of the "webscripts.authenticator.delegatingbasic" bean in the web-framework-config-custom.xml.

I really don't know how to do that, I'm sorry… any suggestions?
Could I simply modify the class and re-compile the package from the source?

Thanks again.

steffen
Champ in-the-making
Champ in-the-making
Sorry, I should have described it more in detail… Yes, you can simply modify the class and re-compile. I just thought it would be nicer to change the feed authentication without modifying the share.war.

The file web-framework-application-context.xml defines the basic authenticaion factory bean:


   <!– HTTP Basic Delegating Authenticator (Servlet based) –>
   <bean id="webscripts.authenticator.delegatingbasic" class="org.alfresco.web.scripts.BasicHttpAuthenticatorFactory">
      <property name="connectorService" ref="connector.service" />
      <property name="endpointId" value="alfresco-feed" />
      <property name="delegate" value="true" />
   </bean>

so thats the bean you want to change the impelmentaion for. to do so it should be enough to add the same snippled in tomcat/shared/classes/alfresco/web-extension/web-framework-config-custom.xml and then change the class attribute to point to your class (with the modified realm section):


   <!– HTTP Basic Delegating Authenticator (Servlet based) –>
   <bean id="webscripts.authenticator.delegatingbasic" class="my.package.MyBasicHttpAuthenticatorFactory">
      <property name="connectorService" ref="connector.service" />
      <property name="endpointId" value="alfresco-feed" />
      <property name="delegate" value="true" />
   </bean>

Your class can then also be placed in tomcat/shared/classes/ . This would make it easier for you to update the share.war in the future … but quit a hassle just to change the realm Smiley Wink

Regards

Steffen

fast3r
Champ on-the-rise
Champ on-the-rise
It works! Thank you very much!

By the way, I had to modify directly the web-framework-application-context.xml file, because settings from web-framework-config-custom.xml seems not to be read… maybe I did something wrong?
I've put my class in /alfresco/tomcat/webapps/share/WEB-INF/classes, because in tomcat/shared/classes it couldn't be found from Alfresco.

This is the web-framework-config-custom.xml content:

<alfresco-config>   

   <!–                           –>
   <!– Web Script Authenticators (KVA)) –>
   <!–                           –>

   <!– HTTP Basic Authenticator (Servlet based) –>
   <bean id="webscripts.authenticator.basic" class="org.alfresco.web.scripts.BasicHttpAuthenticatorFactoryKVA">
      <property name="connectorService" ref="connector.service" />
      <property name="endpointId" value="alfresco-feed" />
   </bean>

   <!– HTTP Basic Delegating Authenticator (Servlet based) –>
   <bean id="webscripts.authenticator.delegatingbasic" class="org.alfresco.web.scripts.BasicHttpAuthenticatorFactoryKVA">
      <property name="connectorService" ref="connector.service" />
      <property name="endpointId" value="alfresco-feed" />
      <property name="delegate" value="true" />
   </bean>
</alfresco-config>