Wednesday, April 25, 2012

Add basic authendication for Jetty

1. In web.xml, it needs to add this
 
 
  
   api
   /*
  
  
   api
  
 
This config indicates that all resources need ROLE api to access.

2. In the jetty folder, find start.ini and make sure the line like this is not commented. Of course to make this realm config right.
etc/jetty-example.xml
3. Go into your etc/jetty-example.xml to make the xml similar like this

    
      
        
          hw xxx Realm
          /etc/realm.properties
          0
        
      
    

4. Go into your etc/realm.properties file to set up realm configuration.

Also these two links are very helpful.
http://docs.codehaus.org/display/JETTY/Realms
http://docs.codehaus.org/display/JETTY/JAAS Recently I found another problem with realm with jetty 8.1.7. When setup as above, the browser does not popup the authentication window but keep reporting error "This web page has a redirect loop" by Chrome. After a struggling by comparing the jetty xml files I found the issue was caused by this section in contenxts/test.xml

      
        true
      

Just comment out this section, the issue was solved.

No comments:

Post a Comment