Browse Source

Configurable cookie name

Brendan Abolivier 8 years ago
parent
commit
f1f42f649f
2 changed files with 23 additions and 7 deletions
  1. 9
    5
      auth.php
  2. 14
    2
      config.html

+ 9
- 5
auth.php View File

@@ -73,9 +73,9 @@ class auth_plugin_macaroons extends auth_plugin_base {
73 73
 		global $DB, $login, $CFG;
74 74
 		$placeholders[0] = "/{{firstname}}/";
75 75
 		$placeholders[1] = "/{{lastname}}/";
76
-		if(!empty($_COOKIE['das-macaroon'])) {
76
+		if(!empty($_COOKIE[$this->config->cookie_name])) {
77 77
 			try {
78
-				$m = Macaroon::deserialize($_COOKIE['das-macaroon']);
78
+				$m = Macaroon::deserialize($_COOKIE[$this->config->cookie_name]);
79 79
 				$v = new Verifier();
80 80
 				$v->setCallbacks([
81 81
 					function($a) {
@@ -205,15 +205,19 @@ class auth_plugin_macaroons extends auth_plugin_base {
205 205
 	 * Processes and stores configuration data for this authentication plugin.
206 206
 	 */
207 207
 	function process_config($config) {
208
-		if(!isset($config->email_config)) {
209
-			$config->email_config = '';
208
+		if(!isset($config->cookie_name)) {
209
+			$config->cookie_name = '';
210 210
 		}
211 211
 		if(!isset($config->secret)) {
212 212
 			$config->secret = '';
213 213
 		}
214
+		if(!isset($config->email_config)) {
215
+			$config->email_config = '';
216
+		}
214 217
 
215
-		set_config('email_config', $config->email_config, self::COMPONENT_NAME);
218
+		set_config('cookie_name', $config->cookie_name, self::COMPONENT_NAME);
216 219
 		set_config('secret', $config->secret, self::COMPONENT_NAME);
220
+		set_config('email_config', $config->email_config, self::COMPONENT_NAME);
217 221
 		return true;
218 222
 	}
219 223
 

+ 14
- 2
config.html View File

@@ -1,10 +1,13 @@
1 1
 <?php
2
-	if(!isset($config->email_config)) {
3
-		$config->email_config = '';
2
+	if(!isset($config->cookie_name)) {
3
+		$config->cookie_name = '';
4 4
 	}
5 5
 	if(!isset($config->secret)) {
6 6
 		$config->secret = '';
7 7
 	}
8
+	if(!isset($config->email_config)) {
9
+		$config->email_config = '';
10
+	}
8 11
 ?>
9 12
 <table cellspacing="0" cellpadding="5" border="0">
10 13
 	<tr>
@@ -14,6 +17,15 @@
14 17
 	</tr>
15 18
 	<tr>
16 19
 		<td align="right">
20
+			<label for="cookie_name">Cookie name</label>
21
+		</td>
22
+		<td>
23
+			<input name="cookie_name" id="cookie_name" type="text" size="50" value="<?php echo $config->cookie_name; ?>" />
24
+		</td>
25
+		<td>Name of the cookie your macaroon is located in.</td>
26
+	</tr>
27
+	<tr>
28
+		<td align="right">
17 29
 			<label for="secret">Secret</label>
18 30
 		</td>
19 31
 		<td>