diff --git a/examples/auth/README.md b/examples/auth/README.md new file mode 100644 index 0000000..05df1b8 --- /dev/null +++ b/examples/auth/README.md @@ -0,0 +1,5 @@ +ScriptForm auth example +======================= + +This example shows how to authenticate users. Everyone must authenticate. Only +user 'test2' is allowed to see and execute the 'only_some_users' form. diff --git a/examples/auth/auth.json b/examples/auth/auth.json new file mode 100644 index 0000000..b5c00fa --- /dev/null +++ b/examples/auth/auth.json @@ -0,0 +1,26 @@ +{ + "title": "Authorization protected", + "users": { + "test": "secret", + "test2": "password" + }, + "forms": { + "do_nothing": { + "title": "Test form", + "description": "You should only see this if you've entered the correct password", + "submit_title": "Do nothing", + "script": "job_do_nothing.sh", + "fields": [ + ] + }, + "only_some_users": { + "title": "Only some users", + "description": "You should only see this if you're user 'test2'", + "submit_title": "Do nothing", + "script": "job_do_nothing.sh", + "allowed_users": ["test2"], + "fields": [ + ] + } + } +} diff --git a/examples/auth/job_do_nothing.sh b/examples/auth/job_do_nothing.sh new file mode 100755 index 0000000..97e7294 --- /dev/null +++ b/examples/auth/job_do_nothing.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "I did nothing very successfully"