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

Commit

Permalink
play pac4j with fixes to handling intended recipient url correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
milinda committed Mar 17, 2015
1 parent 516dc34 commit 4844899
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion play-pac4j_java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.pac4j</groupId>
<artifactId>play-pac4j</artifactId>
<version>1.2.1.htrcv1</version>
<version>1.2.1.htrcv3</version>
</parent>

<artifactId>play-pac4j_java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import play.Play;
import play.libs.F.Function0;
import play.libs.F.Promise;
import play.mvc.Controller;
Expand Down Expand Up @@ -59,7 +60,7 @@ public static Promise<Result> callback() {
final Clients clientsGroup = Config.getClients();

// web context
final JavaWebContext context = new JavaWebContext(request(), response(), session());
final JavaWebContext context = new JavaWebContext(request(), response(), session(), Play.application().configuration().getString("saml.sso.callback", null));

// get the client from its type
final BaseClient client = (BaseClient) clientsGroup.findClient(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.pac4j.play.StorageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.Play;

/**
* This controller is the Java controller to retrieve the user profile or the redirection url to start the authentication process.
Expand Down Expand Up @@ -73,7 +74,7 @@ protected static RedirectAction getRedirectAction(final String clientName, final
throw new TechnicalException("No client defined. Use Config.setClients(clients)");
}
// redirect to the provider for authentication
JavaWebContext webContext = new JavaWebContext(request(), response(), session());
JavaWebContext webContext = new JavaWebContext(request(), response(), session(), Play.application().configuration().getString("saml.sso.callback", null));
RedirectAction action = null;
try {
action = ((BaseClient) clients.findClient(clientName)).getRedirectAction(webContext, false, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ public class JavaWebContext extends BaseResponseContext {

private final Session session;

private String spCallbackUrl = null;

// play api does not expose the scheme, just return http for now
private String scheme = "http";
private String scheme = "https";

public JavaWebContext(final Request request, final Response response, final Session session) {
public JavaWebContext(final Request request, final Response response, final Session session, final String spCallbackUrl) {
this.request = request;
this.response = response;
this.session = session;
this.spCallbackUrl = spCallbackUrl;
}

public void setScheme(String scheme) {
Expand Down Expand Up @@ -124,6 +127,10 @@ public String getScheme() {
}

public String getFullRequestURL() {
return getScheme() + ":https://" + request.host() + request.uri();
if(spCallbackUrl == null) {
return getScheme() + ":https://" + request.host() + request.uri();
} else {
return spCallbackUrl;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import play.Play;
import play.libs.F.Function0;
import play.libs.F.Promise;
import play.mvc.Action;
Expand Down Expand Up @@ -103,7 +104,7 @@ public SimpleResult apply() {
try {
// and compute redirection url
JavaWebContext webContext = new JavaWebContext(context.request(), context.response(), context
.session());
.session(), Play.application().configuration().getString("saml.sso.callback", null));
final RedirectAction action = ((BaseClient) client).getRedirectAction(webContext, true, isAjax);
logger.debug("redirectAction : {}", action);
return convertToPromise(action);
Expand Down
2 changes: 1 addition & 1 deletion play-pac4j_scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.pac4j</groupId>
<artifactId>play-pac4j</artifactId>
<version>1.2.1.htrcv1</version>
<version>1.2.1.htrcv3</version>
</parent>

<artifactId>play-pac4j_scala</artifactId>
Expand Down
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<artifactId>play-pac4j</artifactId>
<packaging>pom</packaging>
<name>Play pac4j</name>
<version>1.2.1.htrcv1</version>
<version>1.2.1.htrcv3</version>
<description>Java and Scala multi protocols (CAS, OAuth, OpenID, HTTP...) client for Play 2.2 framework</description>
<url>https://github.com/leleuj/play-pac4j</url>

Expand Down Expand Up @@ -167,6 +167,20 @@
</pluginManagement>
</build>

<distributionManagement>
<repository>
<id>htrc.nexus.releases</id>
<name>HTRC Release Repository</name>
<url>https://htrc.illinois.edu/nexus/content/repositories/releases/</url>
</repository>

<snapshotRepository>
<id>htrc.nexus.snapshots</id>
<name>HTRC Snapshot Repository</name>
<url>https://htrc.illinois.edu/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

<profiles>
<profile>
<id>release-sign-artifacts</id>
Expand Down

0 comments on commit 4844899

Please sign in to comment.