Last active
November 8, 2018 04:34
-
-
Save line-o/0aa2901efd535a931a784180d15cb0f8 to your computer and use it in GitHub Desktop.
Rough sketch of a password reset for eXist-db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version '3.1'; | |
(:~ | |
this script must be run with a user in the DBA group | |
add this line to your post-install script or run it manually | |
it will set the GID sticky bit | |
chown('/path/to/this/script.xq', 'admin', 'dba') | |
chmod('/path/to/this/script.xq', 'rwxr-S---') | |
:) | |
(:~ | |
do some checks on the password | |
:) | |
declare function local:pass-ok($password) { | |
string-length($password) > 11 | |
}; | |
declare variable $local:user := request:get-parameter('user', '') | |
declare variable $local:pass := request:get-parameter('pass', '') | |
(: check if user exists and new password is good :) | |
if ( | |
sm:user-exists($local:user) and | |
local:pass-ok($local:pass) | |
) | |
then (sm:passwd($local:user, $local:pass)) | |
else ('ERROR') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment