]> git.defcon.no Git - hermes/blob - api/lib/auth_plugins/permitall.php
First stab at a naive permissions-tool
[hermes] / api / lib / auth_plugins / permitall.php
1 <?php
2 /*
3 permitall.php is a sample authentication plugin
4 that responds with 'accept' regardless of what
5 usernames and passwords are passed to it.
6
7 This plugin should serve as a sample plugin:
8 all authentication plugins must implement
9 all functions defined here.
10
11 NOTE that the auth-plugins are for authentication
12 only, and is not doing any kind of authorization.
13
14 NOTE that the auth-plugins handle user
15 authentication for API functions....
16
17 */
18
19 // Is the backend readonly?
20 function authmethod_readonly ()
21 {
22 // Each auth-plugin must specify if users can
23 // be modified in the backend by responding to
24 // the authmethod_readonly with a true/false.
25 //
26 // By returning false to a readonly-poll, the
27 // plugin should be able to add users to the
28 // backend, and also must be able to change
29 // user data and passwords.
30 return true;
31 }
32
33 // Fetch user geckos (basic display info)
34 function authuser_getinfo ( $username )
35 {
36 // Obviously we are returning dummy data here.
37 // on a real auth method, valid returns values
38 // would be a $user array on success, or false
39 // on error.
40 $user['name'] = "Default User";
41 $user['email'] = "example@example.com";
42 return $user;
43 }
44
45 // Update geckos-info for user in backend
46 function authuser_setinfo ( $username, $name, $email )
47 {
48 // RW plugins should return false on failure,
49 // and true on success updating user information
50 // RO plugins should always return false
51 return false;
52 }
53
54 // Change a user-password in the backend
55 function authuser_password ( $username, $password )
56 {
57 // RW plugins should return false on failure,
58 // and true on success updating user information
59 // RO plugins should always return false
60 return false;
61 }
62
63 // Add a user to the backend
64 function authuser_add ( $username, $name, $email, $password )
65 {
66 // RW plugins should return false on failure,
67 // and true on success updating user information
68 // RO plugins should always return false
69 return false;
70 }
71
72 // Remove a user from the backend.
73 function authuser_delete ( $username )
74 {
75 // RW plugins should return false on failure,
76 // and true on success updating user information
77 // RO plugins should always return false
78 return false;
79 }
80
81 // Username+password verification. Basically "login"
82 function authuser_verify ( $username, $password )
83 {
84 // This plugin will always accept.
85 // A real plugin should naturally perform strong user
86 // verification.
87 //
88 // Valid return values from this function:
89 // * -1 -> Failure (e.g. backend not available)
90 // * 0 -> username/password rejected
91 // * 1 -> username/password accepted
92
93 return 1;
94 }
95
96 ?>