authstore.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. {
  2. title: 'Creating Password Verifiers',
  3. crumbs: [
  4. { "Developer's Guide": '../developers/' },
  5. ],
  6. }
  7. <h1>Creating Password Store Verifiers</h1>
  8. <p>You can use a custom password store with GoAhead by defining a password verifier routine.
  9. and then establishing it via the <a
  10. href="../ref/api/goahead.html#group___webs_auth_1gac050abeadb21db4a90197eab284b115b">websSetPasswordStoreVerify</a> API.
  11. <p>Here is a sample verify routine that you can use as a starter:</p>
  12. <pre class="ui code segment">
  13. static bool verifyPassword(Webs *wp)
  14. {
  15. char *password, *roles;
  16. /*
  17. If using Digest auth, compare the digest of the password
  18. */
  19. password = (wp-&gt;digest) ? wp-&gt;digest : wp-&gt;user-&gt;password;
  20. if (!CHECK_PASSWORD(wp-&gt;username, password, &amp;roles)) {
  21. return 0;
  22. }
  23. /*
  24. Create the user inside GoAhead and set the user roles/abilities
  25. */
  26. if ((wp-&gt;user = websLookupUser(wp-&gt;username)) == 0) {
  27. if ((wp-&gt;user = websAddUser(wp-&gt;username, 0, roles)) == 0) {
  28. return 0;
  29. }
  30. websSetUserRoles(wp-&gt;username, roles);
  31. }
  32. return 1;
  33. }
  34. </pre>