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.

Signed-off-by: Peter Kullmann <[email protected]>
  • Loading branch information
Peter Kullmann committed Dec 9, 2015
1 parent d82ecaa commit 1b5ca84
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class SecurityFilter implements Filter {
private AtomicReference<AuthorityAdmin> authorityAdminRef = new AtomicReference<AuthorityAdmin>();
private volatile boolean reported;
private String realm;
private boolean allowAuthOverNonSecureLine = false;

@ObjectClassDefinition
@interface Config {
Expand All @@ -64,6 +65,11 @@ public class SecurityFilter implements Filter {
String pattern();

String osgi_http_whiteboard_filter_regex();

@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 @@ -96,8 +102,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 1b5ca84

Please sign in to comment.