Skip to content

Commit

Permalink
Make Realm removal optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ducar committed Mar 21, 2017
1 parent bbc2c5b commit af292d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions RemoteUserJiraAuth/RemoteUserJiraAuth.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ header=x-forward-name
#trustedhosts=192.168.0.1,127.0.0.1
#trustedhosts=
trustedhosts=10.1.1.100,127.0.0.1

## Split username on REALM and use only part without it, example:
## [email protected] will become by default joe.black
## Default is set to set to true, Comment out and set to false if you need full name
#removeRealm=false
2 changes: 1 addition & 1 deletion RemoteUserJiraAuth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>anguswarren.jira</groupId>
<artifactId>RemoteUserJiraAuth</artifactId>
<version>1.2</version>
<version>1.3</version>

<organization>
<name>Angus Warren</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,17 @@ public Principal getUser(HttpServletRequest request, HttpServletResponse respons
}

if (remoteuser != null) {
String[] username = remoteuser.split("@");
user = getUser(username[0]);
Boolean removeRealm = new Boolean(true);
if (p.getProperty("removeRealm") != null) {
removeRealm = Boolean.parseBoolean(p.getProperty("removeRealm"));
}
if (removeRealm) {
log.debug("Trying to resolve remoteuser: " + remoteuser.split("@")[0]);
user = getUser(remoteuser.split("@")[0]);
} else {
log.debug("Trying to resolve remoteuser: " + remoteuser);
user = getUser(remoteuser);
}
log.debug("Logging in with username: " + user);
request.getSession().setAttribute(JiraSeraphAuthenticator.LOGGED_IN_KEY, user);
request.getSession().setAttribute(JiraSeraphAuthenticator.LOGGED_OUT_KEY, null);
Expand Down

0 comments on commit af292d8

Please sign in to comment.