mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
filter set up now includes both Acegi and legacy BASIC-only code.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6066 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
902f5eb33c
commit
47a7b0e69e
3 files changed
+73
-1
No files matched your search
@@ -0,0 +1,69 @@
|
||||
package hudson.security;
|
||||
|
||||
import hudson.model.Hudson;
|
||||
import hudson.util.spring.BeanBuilder;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* {@link Filter} that Hudson uses to implement security support.
|
||||
*
|
||||
* <p>
|
||||
* This is the instance the servlet container creates, but
|
||||
* internally this is just a dispatcher that delegates the request
|
||||
* to the appropriate filter pipeline based on the current
|
||||
* configuration.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class HudsonFilter implements Filter {
|
||||
/**
|
||||
* To be used with {@link SecurityMode#LEGACY}.
|
||||
*/
|
||||
private Filter legacy;
|
||||
/**
|
||||
* To be used with {@link SecurityMode#SECURED}.
|
||||
*/
|
||||
private Filter acegi;
|
||||
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
legacy = new BasicAuthenticationFilter();
|
||||
legacy.init(filterConfig);
|
||||
|
||||
BeanBuilder builder = new BeanBuilder();
|
||||
builder.parse(getClass().getResourceAsStream("Filters.groovy"));
|
||||
acegi = (Filter) builder.createApplicationContext().getBean("filter");
|
||||
acegi.init(filterConfig);
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
Hudson h = Hudson.getInstance();
|
||||
if(h==null) {
|
||||
// Hudson is starting up.
|
||||
chain.doFilter(request,response);
|
||||
return;
|
||||
}
|
||||
switch (h.getSecurity()) {
|
||||
case LEGACY:
|
||||
legacy.doFilter(request,response,chain);
|
||||
break;
|
||||
case SECURED:
|
||||
acegi.doFilter(request,response,chain);
|
||||
break;
|
||||
case UNSECURED:
|
||||
chain.doFilter(request,response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
legacy.destroy();
|
||||
acegi.destroy();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ public enum SecurityMode {
|
||||
* In this model, an user is either admin or not. An admin user
|
||||
* can do anything, and non-admin user can only browse.
|
||||
* Authentication is performed by the container.
|
||||
* <p>
|
||||
* This is the only secured mode of Hudson up to 1.160.
|
||||
* This is maintained only for backward compatibility.
|
||||
*/
|
||||
LEGACY,
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user