I need to use Kong and OAuth to build a web app and some other APIs.
Now I have:
- A server for Kong.
- A server storages User Information such as id, username, password. Named it as User-Database.
I need to:
- The web app and some others are going to use APIs with OAuth2.0;
- APIs are provided by Kong only.
According to the document on Kong, I designed out a Resource Owner Password Credential one., and it is like this:
(These APIs are just for getting accessToken, no authentication method)
- User-End post Username&Password to Kong
- Kong routes it to User-Database.
- User-Database verifies the username and password, and post a request to Kong. The request will include username, password, provision_key, autherticated_userid. (*)
- Kong will response a access_token to User-Database, and will also remeber the autherticated_userid, access_token and scope. Kong will remeber them before the access-token expired.
- After User-Database received the response from Kong, it will response too for step 1 & 2, and finally the User-End will get the access-token for future use.
(Got the access-token)
- User-End is going to send request to APIs which need authentication.
There is something I couldn't understand at the step 3.
According to the document on Kong:
$ curl https://your.api.com/oauth2/token \
--header "Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW" \
--data "client_id=XXX" \
--data "client_secret=XXX" \
--data "scope=XXX" \
--data "provision_key=XXX" \
--data "authenticated_userid=XXX" \
--data "username=XXX" \
--data "password=XXX"
The provision_key is the key the plugin has generated when it has been added to the API, while authenticated_userid is the ID of the end user whose username and password belong to.
Should I storage all the users' information to my self-managed user-database and Kong both?
Or is there something I missed or I could optimizate ?