-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
248 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: REST auth | ||
--- | ||
|
||
There are multiple ways to externalize authentication, rather than [local JSON authentication](/server/jsonconfig). | ||
This page explains how to use the REST authenticator. | ||
With the REST method, you provide your own HTTP endpoint. | ||
You can use any method like GET or POST, and you can customize unFTP to support your API. | ||
|
||
## Set up | ||
|
||
Example: | ||
|
||
```sh | ||
unftp \ | ||
--auth-type rest \ | ||
--auth-rest-method POST \ | ||
--auth-rest-url http://localhost:5000/v1/ftp-auth \ | ||
--auth-rest-body '{"username":"{USER}","password":"{PASS}"}' \ | ||
--auth-rest-selector /status \ | ||
--auth-rest-regex successful | ||
``` | ||
|
||
Let's say, a user `alice` logs in on the unFTP server. | ||
With the above configuration unFTP will build an HTTP POST authentication request for http://localhost:5000/v1/ftp-auth | ||
It will replace the placeholders `{USER}`, and `{PASS}` with the given FTP username and password: | ||
|
||
```json | ||
{"username":"alice","password":"abc1234"} | ||
``` | ||
|
||
And, if the login was successful, the server should respond with something like: | ||
|
||
```json | ||
{"message":"User logged in.","status":"successful"} | ||
``` | ||
|
||
The REST authenticator uses the `/status` JSON pointer, and matches it to `"successful"`. | ||
|
||
Aside from the placeholders `{USER}` and `{PASS}` you can use `{IP}`. | ||
That will add the source IP address of the connected client. | ||
That is in case if you want to perform client-IP whitelisting, next to regular username and password. | ||
|
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
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
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
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