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

+ 14
- 2
config.html View File

1
 <?php
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
 	if(!isset($config->secret)) {
5
 	if(!isset($config->secret)) {
6
 		$config->secret = '';
6
 		$config->secret = '';
7
 	}
7
 	}
8
+	if(!isset($config->email_config)) {
9
+		$config->email_config = '';
10
+	}
8
 ?>
11
 ?>
9
 <table cellspacing="0" cellpadding="5" border="0">
12
 <table cellspacing="0" cellpadding="5" border="0">
10
 	<tr>
13
 	<tr>
14
 	</tr>
17
 	</tr>
15
 	<tr>
18
 	<tr>
16
 		<td align="right">
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
 			<label for="secret">Secret</label>
29
 			<label for="secret">Secret</label>
18
 		</td>
30
 		</td>
19
 		<td>
31
 		<td>