forked from AngusWarren/remoteuserauth
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8f2514
commit a938efc
Showing
7 changed files
with
187 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
To avoid future confusion, we recommend that you include a license with your plugin. | ||
This file is simply a reminder. | ||
|
||
For a template license you can have a look at: http://www.opensource.org/licenses/ | ||
|
||
Atlassian releases most of its modules under the Apache2 license: http://opensource.org/licenses/Apache-2.0 | ||
Copyright 2011 Angus Warren | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>anguswarren.confluence</groupId> | ||
<artifactId>RemoteUserConfluenceAuth</artifactId> | ||
<version>1.1</version> | ||
|
||
<organization> | ||
<name>Angus Warren</name> | ||
<url>http://wiki.warren.bz</url> | ||
</organization> | ||
|
||
<name>anguswarren.confluence.RemoteUserConfluenceAuth</name> | ||
<description>This is a custom Seraph filter developed by Angus Warren to authenticate based on the remote_user variable set by Apache</description> | ||
<packaging>atlassian-plugin</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.10</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.atlassian.confluence</groupId> | ||
<artifactId>confluence</artifactId> | ||
<version>${confluence.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.4</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.atlassian.maven.plugins</groupId> | ||
<artifactId>maven-confluence-plugin</artifactId> | ||
<version>${amps.version}</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<productVersion>${confluence.version}</productVersion> | ||
<productDataVersion>${confluence.data.version}</productDataVersion> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<properties> | ||
<confluence.version>5.7</confluence.version> | ||
<confluence.data.version>5.7</confluence.data.version> | ||
<amps.version>5.0.13</amps.version> | ||
<plugin.testrunner.version>1.2.3</plugin.testrunner.version> | ||
</properties> | ||
|
||
</project> |
68 changes: 68 additions & 0 deletions
68
RemoteUserConfluenceAuth/src/main/java/anguswarren/confluence/RemoteUserConfluenceAuth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright 2011 Angus Warren | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package anguswarren.confluence; | ||
|
||
import org.apache.log4j.Category; | ||
import java.security.Principal; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import com.atlassian.confluence.user.ConfluenceAuthenticator; | ||
|
||
public class RemoteUserConfluenceAuth extends ConfluenceAuthenticator | ||
{ | ||
private static final Category log = Category.getInstance(RemoteUserConfluenceAuth.class); | ||
|
||
public Principal getUser(HttpServletRequest request, HttpServletResponse response) | ||
{ | ||
Principal user = null; | ||
try | ||
{ | ||
if(request.getSession() != null && request.getSession().getAttribute(ConfluenceAuthenticator.LOGGED_IN_KEY) != null) | ||
{ | ||
log.debug("Session found; user already logged in"); | ||
user = (Principal) request.getSession().getAttribute(ConfluenceAuthenticator.LOGGED_IN_KEY); | ||
String username = user.getName(); | ||
user = getUser(username); | ||
} | ||
else | ||
{ | ||
log.debug("Trying RemoteUserConfluenceAuth SSO"); | ||
String remoteuser = request.getRemoteUser(); | ||
log.debug("remote_user set to: " + remoteuser); | ||
if(remoteuser != null) | ||
{ | ||
String[] username = remoteuser.split("@"); | ||
user = getUser(username[0]); | ||
log.debug("Logging in with username: " + user); | ||
request.getSession().setAttribute(ConfluenceAuthenticator.LOGGED_IN_KEY, user); | ||
request.getSession().setAttribute(ConfluenceAuthenticator.LOGGED_OUT_KEY, null); | ||
} | ||
else | ||
{ | ||
log.warn("remote_user is null"); | ||
return null; | ||
} | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
log.warn("Exception: " + e, e); | ||
} | ||
return user; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
RemoteUserConfluenceAuth/src/main/resources/atlassian-plugin.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="1"> | ||
<plugin-info> | ||
<description>${project.description}</description> | ||
<version>${project.version}</version> | ||
<vendor name="${project.organization.name}" url="${project.organization.url}" /> | ||
</plugin-info> | ||
</atlassian-plugin> |
Binary file not shown.
Binary file not shown.