Skip to content

Commit

Permalink
Merge pull request #25 from redcape/custom-logout-link
Browse files Browse the repository at this point in the history
Enable custom log out redirect
  • Loading branch information
wilderrodrigues committed Jun 15, 2016
2 parents fc7b580 + 195096f commit a728d20
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
import org.jenkinsci.plugins.reverse_proxy_auth.service.ProxyLDAPUserDetailsService;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.springframework.dao.DataAccessException;
import org.springframework.web.context.WebApplicationContext;

Expand Down Expand Up @@ -265,8 +266,13 @@ public class ReverseProxySecurityRealm extends SecurityRealm {

private final String emailAddressLdapAttribute;

/**
* Custom post logout url
*/
public final String customLogOutUrl;

@DataBoundConstructor
public ReverseProxySecurityRealm(String forwardedUser, String headerGroups, String headerGroupsDelimiter, String server, String rootDN, boolean inhibitInferRootDN,
public ReverseProxySecurityRealm(String forwardedUser, String headerGroups, String headerGroupsDelimiter, String customLogOutUrl, String server, String rootDN, boolean inhibitInferRootDN,
String userSearchBase, String userSearch, String groupSearchBase, String groupSearchFilter, String groupMembershipFilter, String groupNameAttribute, String managerDN, String managerPassword,
Integer updateInterval, boolean disableLdapEmailResolver, String displayNameLdapAttribute, String emailAddressLdapAttribute) {

Expand All @@ -278,6 +284,13 @@ public ReverseProxySecurityRealm(String forwardedUser, String headerGroups, Stri
} else {
this.headerGroupsDelimiter = "|";
}

if(!StringUtils.isBlank(customLogOutUrl)) {
this.customLogOutUrl = customLogOutUrl;
} else {
this.customLogOutUrl = null;
}

this.server = fixEmptyAndTrim(server);
this.managerDN = fixEmpty(managerDN);
this.managerPassword = Scrambler.scramble(fixEmpty(managerPassword));
Expand Down Expand Up @@ -537,7 +550,20 @@ public void destroy() {

@Override
public boolean canLogOut() {
return false;
if (customLogOutUrl == null) {
return false;
} else {
return true;
}
}

@Override
public String getPostLogOutUrl(StaplerRequest req, Authentication auth) {
if (customLogOutUrl == null) {
return super.getPostLogOutUrl(req, auth);
} else {
return customLogOutUrl;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ THE SOFTWARE.
<f:textbox field="headerGroupsDelimiter" default="|" />
</f:entry>
<f:advanced>
<f:entry title="${%Custom Log Out URL}" >
<f:textbox name="customLogOutUrl" value="${instance.customLogOutUrl}" />
</f:entry>
<f:entry title="${%Server}" >
<f:textbox name="server" value="${instance.server}"
checkUrl="'${rootURL}/securityRealms/LDAPSecurityRealm/serverCheck?field=server&amp;server='+encodeURIComponent(this.value)+'&amp;managerDN='+encodeURIComponent(this.form.elements['managerDN'].value)+'&amp;managerPassword='+encodeURIComponent(this.form.elements['managerPassword'].value)"/>
Expand Down

0 comments on commit a728d20

Please sign in to comment.