Browse Source

Configurable macaroon secret

Brendan Abolivier 8 years ago
parent
commit
d85e9f8267
2 changed files with 31 additions and 17 deletions
  1. 5
    1
      auth.php
  2. 26
    16
      config.html

+ 5
- 1
auth.php View File

83
 					}
83
 					}
84
 				]);
84
 				]);
85
 
85
 
86
-				if($v->verify($m, "pocsecret")) {
86
+				if($v->verify($m, $this->config->secret)) {
87
 					$name = explode(";", $m->getIdentifier());
87
 					$name = explode(";", $m->getIdentifier());
88
 					$login = join("", $name);
88
 					$login = join("", $name);
89
 					$user = authenticate_user_login($login, null);
89
 					$user = authenticate_user_login($login, null);
208
 		if(!isset($config->email_config)) {
208
 		if(!isset($config->email_config)) {
209
 			$config->email_config = '';
209
 			$config->email_config = '';
210
 		}
210
 		}
211
+		if(!isset($config->secret)) {
212
+			$config->secret = '';
213
+		}
211
 
214
 
212
 		set_config('email_config', $config->email_config, self::COMPONENT_NAME);
215
 		set_config('email_config', $config->email_config, self::COMPONENT_NAME);
216
+		set_config('secret', $config->secret, self::COMPONENT_NAME);
213
 		return true;
217
 		return true;
214
 	}
218
 	}
215
 
219
 

+ 26
- 16
config.html View File

2
 	if(!isset($config->email_config)) {
2
 	if(!isset($config->email_config)) {
3
 		$config->email_config = '';
3
 		$config->email_config = '';
4
 	}
4
 	}
5
+	if(!isset($config->secret)) {
6
+		$config->secret = '';
7
+	}
5
 ?>
8
 ?>
6
 <table cellspacing="0" cellpadding="5" border="0">
9
 <table cellspacing="0" cellpadding="5" border="0">
7
-    <tr>
8
-        <td colspan="3">
9
-            <h3>Macaroons configuration</h3>
10
-        </td>
11
-    </tr>
12
-    <tr>
13
-        <td align="right">
14
-            <label for="email_config">
15
-		E-mail template
16
-            </label>
17
-        </td>
18
-        <td>
19
-		<input name="email_config" id="email_config" type="text" size="50" value="<?php echo $config->email_config; ?>" />
20
-        </td>
21
-        <td>Template for emails. Available placeholders are {{firstname}} and {{lastname}}.<br />
10
+	<tr>
11
+		<td colspan="3">
12
+			<h3>Macaroons configuration</h3>
13
+		</td>
14
+	</tr>
15
+	<tr>
16
+		<td align="right">
17
+			<label for="secret">Secret</label>
18
+		</td>
19
+		<td>
20
+			<input name="secret" id="secret" type="text" size="50" value="<?php echo $config->secret; ?>" />
21
+		</td>
22
+		<td>The secret your macaroon was signed with</td>
23
+	</tr>
24
+	<tr>
25
+		<td align="right">
26
+			<label for="email_config">E-mail template</label>
27
+		</td>
28
+		<td>
29
+			<input name="email_config" id="email_config" type="text" size="50" value="<?php echo $config->email_config; ?>" />
30
+		</td>
31
+		<td>Template for emails. Available placeholders are {{firstname}} and {{lastname}}.<br />
22
 eg: {{firstname}}.{{lastname}}@company.tld</td>
32
 eg: {{firstname}}.{{lastname}}@company.tld</td>
23
-    </tr>
33
+	</tr>
24
 </table>
34
 </table>