From 5aa9ebce2028efe5645123a693e3155baa956bde Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Mon, 27 Feb 2012 15:15:46 +0100 Subject: [PATCH] Added security to admin pages --- app/controllers/Partys.java | 3 ++- app/controllers/Security.java | 11 +++++++++++ app/controllers/Users.java | 4 +++- conf/application.conf | 2 +- conf/messages | 1 + conf/routes | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 app/controllers/Security.java diff --git a/app/controllers/Partys.java b/app/controllers/Partys.java index a47fa84..5e06fdd 100644 --- a/app/controllers/Partys.java +++ b/app/controllers/Partys.java @@ -2,6 +2,7 @@ package controllers; import play.*; import play.mvc.*; - + +@With(Secure.class) public class Partys extends CRUD { } diff --git a/app/controllers/Security.java b/app/controllers/Security.java new file mode 100644 index 0000000..f3224f6 --- /dev/null +++ b/app/controllers/Security.java @@ -0,0 +1,11 @@ +package controllers; + +import models.*; + +public class Security extends Secure.Security { + + static boolean authenticate(String username, String password) { + return User.connect(username, password) != null; + } + +} diff --git a/app/controllers/Users.java b/app/controllers/Users.java index 29f4dd3..907e997 100644 --- a/app/controllers/Users.java +++ b/app/controllers/Users.java @@ -2,6 +2,8 @@ package controllers; import play.*; import play.mvc.*; - + + +@With(Secure.class) public class Users extends CRUD { } diff --git a/conf/application.conf b/conf/application.conf index 5629d1c..56bc829 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -221,4 +221,4 @@ blog.title=Yet another blog blog.baseline=We will write about nothing # Import the secure module -% module.secure=${play.path}/modules/secure +module.secure=${play.path}/modules/secure diff --git a/conf/messages b/conf/messages index b51f294..0e07937 100644 --- a/conf/messages +++ b/conf/messages @@ -1,3 +1,4 @@ # You can specialize this file for each language. # For example, for French create a messages.fr file # +Partys=Parties diff --git a/conf/routes b/conf/routes index 24c4663..800e660 100644 --- a/conf/routes +++ b/conf/routes @@ -12,7 +12,7 @@ GET /party/{id} Application.showParty * /admin/ module:crud # Import Secure routes -# geen gezicht * / module:secure +* / module:secure # Ignore favicon requests GET /favicon.ico 404 -- 2.39.5