12345678910111213141516171819202122232425262728293031323334 |
- {
- title: 'Creating Password Verifiers',
- crumbs: [
- { "Developer's Guide": '../developers/' },
- ],
- }
- <h1>Creating Password Store Verifiers</h1>
- <p>You can use a custom password store with GoAhead by defining a password verifier routine.
- and then establishing it via the <a
- href="../ref/api/goahead.html#group___webs_auth_1gac050abeadb21db4a90197eab284b115b">websSetPasswordStoreVerify</a> API.
- <p>Here is a sample verify routine that you can use as a starter:</p>
- <pre class="ui code segment">
- static bool verifyPassword(Webs *wp)
- {
- char *password, *roles;
- /*
- If using Digest auth, compare the digest of the password
- */
- password = (wp->digest) ? wp->digest : wp->user->password;
- if (!CHECK_PASSWORD(wp->username, password, &roles)) {
- return 0;
- }
- /*
- Create the user inside GoAhead and set the user roles/abilities
- */
- if ((wp->user = websLookupUser(wp->username)) == 0) {
- if ((wp->user = websAddUser(wp->username, 0, roles)) == 0) {
- return 0;
- }
- websSetUserRoles(wp->username, roles);
- }
- return 1;
- }
- </pre>
|