Koha/installer/data/mysql
Julian Maurice 43a4b3c22c Bug 20402: Implement OAuth2 authentication for REST API
It implements only the "client credentials" flow with no scopes
support. API clients are tied to an existing patron and have the same
permissions as the patron they are tied to.
API Clients are defined in $KOHA_CONF.

Test plan:
0. Install Net::OAuth2::AuthorizationServer 0.16
1. In $KOHA_CONF, add an <api_client> element under <config>:
     <api_client>
       <client_id>$CLIENT_ID</client_id>
       <client_secret>$CLIENT_SECRET</client_secret>
       <patron_id>X</patron_id> <!-- X is an existing borrowernumber -->
     </api_client>
2. Apply patch, run updatedatabase.pl and reload starman
3. Install Firefox extension RESTer [1]
4. In RESTer, go to "Authorization" tab and create a new OAuth2
   configuration:
   - OAuth flow: Client credentials
   - Access Token Request Method: POST
   - Access Token Request Endpoint: http://$KOHA_URL/api/v1/oauth/token
   - Access Token Request Client Authentication: Credentials in request
     body
   - Client ID: $CLIENT_ID
   - Client Secret: $CLIENT_SECRET
5. Click on the newly created configuration to generate a new token
   (which will be valid only for an hour)
6. In RESTer, set HTTP method to GET and url to
   http://$KOHA_URL/api/v1/patrons then click on SEND
   If patron X has permission 'borrowers', it should return 200 OK
   with the list of patrons
   Otherwise it should return 403 with the list of required permissions
   (Please test both cases)
7. Wait an hour (or run the following SQL query:
   UPDATE oauth_access_tokens SET expires = 0) and repeat step 6.
   You should have a 403 Forbidden status, and the token must have been
   removed from the database.
8. Create a bunch of tokens using RESTer, make some of them expires
   using the previous SQL query, and run the following command:
     misc/cronjobs/cleanup_database.pl --oauth-tokens
   Verify that expired tokens were removed, and that the others are
   still there
9. prove t/db_dependent/api/v1/oauth.t

[1] https://addons.mozilla.org/en-US/firefox/addon/rester/

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2018-05-08 15:55:42 -03:00
..
atomicupdate Bug 20402: Implement OAuth2 authentication for REST API 2018-05-08 15:55:42 -03:00
de-DE Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
en Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
es-ES Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
fr-CA Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
fr-FR Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
it-IT Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
mandatory Bug 20482: Correct Terminology codes to Bibliographic ones 2018-04-24 12:04:45 -03:00
nb-NO Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
pl-PL Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
ru-RU Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
uk-UA Bug 19287: Add CANCEL_HOLD_ON_LOST to installer files for all languages 2018-04-23 12:55:59 -03:00
account_offset_types.sql Bug 18790: Add ability to void payments 2018-04-19 12:32:21 -03:00
audio_alerts.sql
backfill_statistics.pl Bug 16011: $VERSION - Remove comments 2016-03-24 17:20:29 +00:00
fix_unclosed_nonaccruing_fines_bug17135.pl Bug 17135: [QA Follow-up] Changes as to reporting 2016-09-16 10:47:03 +00:00
kohastructure.sql Bug 20073: Move Elasticsearch configs to yaml files and improve the default settings. 2018-04-23 14:22:16 -03:00
labels_upgrade.pl
patroncards_upgrade.pl
sysprefs.sql Bug 19466: Turn AutoCalc off for new installs 2018-05-03 11:03:48 -03:00
update22to30.pl
updatedatabase.pl Bug 11317: DBRev 17.12.00.041 2018-05-03 13:40:11 -03:00
userflags.sql Bug 15492: New sysprefs and permissions 2018-03-26 17:31:18 -03:00
userpermissions.sql Bug 11317: Add a way to access files from the intranet 2018-05-03 13:26:49 -03:00