3 | | May First/People Link provides a web-based API for verifying login credentials called "login-service". It is designed to allow applications to verify that a given username and password is valid. It takes as input a username, password, and application id, and responds with either a 1 (indicating invalid) or a 0 indicating a valid username and password. |
| 3 | May First/People Link provides a web-based API for verifying login credentials called "login-service". It is designed to allow applications to verify that a given username and password is valid or that a given username exists. |
| 4 | |
| 5 | In "check" mode it takes as input a username, password, and application id, and responds with either a no (indicating invalid) or a yes indicating a valid username and password or error. |
| 6 | |
| 7 | In "user" mode it takes as input a username and application id, and responds with either a no (indicating the username doesn't exist) or a yes indicating a valid username or error. |
22 | | user="$1" |
23 | | pass="$2" |
24 | | app_id="$3" |
25 | | out=$(curl -s "https://id.mayfirst.org:8080/check?user=$user&password=$pass&app_id=$3") |
| 26 | |
| 27 | service="$1" |
| 28 | app_id="$2" |
| 29 | user="$3" |
| 30 | pass="$4" |
| 31 | |
| 32 | if [ -z "$service" -o -z "$app_id" -o -z "$user" ]; then |
| 33 | printf "Please pass service app_id and user as the first three arguments.\n" |
| 34 | exit 2 |
| 35 | fi |
| 36 | |
| 37 | if [ "$service" != "user" -a "$service" != "check" ]; then |
| 38 | printf "Service must be user or check.\n" |
| 39 | exit 2 |
| 40 | fi |
| 41 | |
| 42 | if [ "$service" = "check" -a -z "$pass" ]; then |
| 43 | printf "If you pass user as the service, the last argument should be a password.\n" |
| 44 | exit 2 |
| 45 | fi |
| 46 | |
| 47 | out=$(curl -s "https://id.mayfirst.org:8080/${service}?user=${user}&password=${pass}&app_id=${app_id}") |
| 48 | |