Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Allow non-secure contexts (configurable)
Browse files Browse the repository at this point in the history
Sometimes it is necessary to allow authentication (even basic auth) over
an open insecure line: 
- Test environments (in the IDE)
- Behind reverse Proxies where SSL handling is done by the proxy

This change allows to use the authenticator filter even if the servlet
request says it's not secure.

BTW: A missing return statement is added.
  • Loading branch information
Peter Kullmann committed Nov 14, 2014
1 parent 92e2811 commit d8410d4
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class SecurityFilter implements Filter {
private AtomicReference<AuthorityAdmin> authorityAdminRef = new AtomicReference<AuthorityAdmin>();
private volatile boolean reported;
private String realm;
private boolean allowAuthOverNonSecureLine = false;

interface Config {
@Meta.AD(deflt = DEFAULT_REALM)
Expand All @@ -56,6 +57,11 @@ interface Config {
String filter();

String alias();

@Meta.AD(deflt = "false", description="Authentication over non-secure lines is dangerous. "
+ "But sometimes it is necessary, eg behind a reverse "
+ "proxy which handles HTTPS. ")
boolean allowAuthOverNonSecureLine();
}

/*
Expand Down Expand Up @@ -89,8 +95,10 @@ public Void call() throws Exception {
// and an open line is basically all,well, eh, open
//

if (!req.isSecure())
if (!allowAuthOverNonSecureLine && !req.isSecure()) {
run(null, runAs);
return;
}

if (req instanceof HttpServletRequest) {

Expand Down

0 comments on commit d8410d4

Please sign in to comment.