Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #268 from mkurz/AuthenticateDIFix
Browse files Browse the repository at this point in the history
Added injected Authenticate controller
  • Loading branch information
mkurz committed Jul 3, 2015
2 parents 7ceb16e + 98b247e commit e5eef20
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
13 changes: 1 addition & 12 deletions code/app/com/feth/play/module/pa/controllers/Authenticate.java
@@ -1,22 +1,11 @@
package com.feth.play.module.pa.controllers;

import play.mvc.Controller;
import play.mvc.Http.Response;
import play.mvc.Result;

import com.feth.play.module.pa.PlayAuthenticate;

public class Authenticate extends Controller {


private static final String PAYLOAD_KEY = "p";

public static void noCache(final Response response) {
// http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers
response.setHeader(Response.CACHE_CONTROL, "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader(Response.PRAGMA, "no-cache"); // HTTP 1.0.
response.setHeader(Response.EXPIRES, "0"); // Proxies.
}
public class Authenticate extends AuthenticateBase {

public static Result authenticate(final String provider) {
noCache(response());
Expand Down
18 changes: 18 additions & 0 deletions code/app/com/feth/play/module/pa/controllers/AuthenticateBase.java
@@ -0,0 +1,18 @@
package com.feth.play.module.pa.controllers;

import play.mvc.Controller;
import play.mvc.Http.Response;

import com.feth.play.module.pa.PlayAuthenticate;

public class AuthenticateBase extends Controller {

protected static final String PAYLOAD_KEY = "p";

public static void noCache(final Response response) {
// http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers
response.setHeader(Response.CACHE_CONTROL, "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader(Response.PRAGMA, "no-cache"); // HTTP 1.0.
response.setHeader(Response.EXPIRES, "0"); // Proxies.
}
}
20 changes: 20 additions & 0 deletions code/app/com/feth/play/module/pa/controllers/AuthenticateDI.java
@@ -0,0 +1,20 @@
package com.feth.play.module.pa.controllers;

import play.mvc.Controller;
import play.mvc.Result;

import com.feth.play.module.pa.PlayAuthenticate;

public class AuthenticateDI extends AuthenticateBase {

public Result authenticate(final String provider) {
noCache(response());
final String payload = request().getQueryString(PAYLOAD_KEY);
return PlayAuthenticate.handleAuthentication(provider, ctx(), payload);
}

public Result logout() {
noCache(response());
return PlayAuthenticate.logout(session());
}
}

0 comments on commit e5eef20

Please sign in to comment.