Skip to content

Commit

Permalink
play-cms 2.2: use play-secure 0.5 instead of Play! built-in module "s…
Browse files Browse the repository at this point in the history
…ecure"
  • Loading branch information
Andrei Solntsev, Marek Kusmin committed Feb 13, 2017
1 parent 0df6baf commit 5b93f41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== Changelog

=== 2.2 (13.02.2017)
* use play-secure 0.5 instead of Play! built-in module "secure"

=== 2.1 (21.01.2017)
* use play-rebel 0.6, extend RebelController

Expand Down
37 changes: 11 additions & 26 deletions app/controllers/cms/Profiler.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
package controllers.cms;

import controllers.Secure.Security;
import play.Logger;
import play.Play;
import play.classloading.enhancers.ControllersEnhancer.ControllerSupport;
import play.mvc.Scope.Session;
import play.utils.Java;
import play.security.AuthorizationService;

import javax.inject.Inject;

public class Profiler implements ControllerSupport {
@Inject static AuthorizationService authorizationService;

public class Profiler {
public static boolean canEdit(String pageName) {
if (Session.current().get("username") == null)
return false;

String profile = Play.configuration.getProperty("cms.profile", "admin");
boolean result;
try {
result = (Boolean) invoke(Security.class, "check", profile);
return result;
}
catch (Throwable e) {
Logger.error(e, "While checking cms profile");
return false;
}
return authorizationService.check(profile);
}

public static boolean canEnter() {
if (Session.current().get("username") == null)
return false;
String profile = Play.configuration.getProperty("cms.profile", "admin");
boolean result;
try {
result = (Boolean) invoke(Security.class, "check", profile);
return result;
}
catch (Throwable e) {
Logger.error(e, "While checking cms profile");
return false;
}
}

private static Object invoke(Class<?> original, String m, Object... args) throws Throwable {
return Java.invokeChildOrStatic(original, m, args);
String profile = Play.configuration.getProperty("cms.profile", "admin");
return authorizationService.check(profile);
}
}
8 changes: 5 additions & 3 deletions conf/dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
self: play -> cms 2.1
self: play -> cms 2.2

require:
- play [1.2,1.4]
- play -> secure
- play-codeborne -> rebel 0.6

- play-codeborne -> secure 0.5
- play-codeborne -> rebel 0.6.5

repositories:

- codeborne-modules-jars:
type: http
artifact: https://repo.codeborne.com/play-[module]/[module]-[revision].jar
contains:
- play-codeborne -> secure
- play-codeborne -> rebel

0 comments on commit 5b93f41

Please sign in to comment.