Parcourir la source

Configurable macaroon secret

Brendan Abolivier il y a 7 ans
Parent
révision
d85e9f8267
2 fichiers modifiés avec 31 ajouts et 17 suppressions
  1. 5
    1
      auth.php
  2. 26
    16
      config.html

+ 5
- 1
auth.php Voir le fichier

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

+ 26
- 16
config.html Voir le fichier

@@ -2,23 +2,33 @@
2 2
 	if(!isset($config->email_config)) {
3 3
 		$config->email_config = '';
4 4
 	}
5
+	if(!isset($config->secret)) {
6
+		$config->secret = '';
7
+	}
5 8
 ?>
6 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 32
 eg: {{firstname}}.{{lastname}}@company.tld</td>
23
-    </tr>
33
+	</tr>
24 34
 </table>