To install the function on the Web Server, add the following Init directive to magnus.conf to load the compiled function:
Init fn=load-modules
shlib="path"
funcs=hardcoded-auth
Inside the default object in obj.conf, add the following AuthTrans directive:
AuthTrans fn=basic-auth
auth-type="basic"
userfn=hardcoded-auth
userdb=unused
|
Note that this function does not actually enforce authorization requirements. It only takes given information and tells the server whether it is correct. The PathCheck function require-auth performs the enforcement. Therefore, add the following PathCheck directive:
PathCheck fn=require-auth
realm="test realm"
auth-type="basic"
The source code for this example is in the auth.c file in the install-dir/samples/nsapi/directory.