sul-dlss / sdr-client

SDR API client (in Ruby)
https://sul-dlss.github.io/sdr-api/
Other
0 stars 1 forks source link

Default to CLI authentication via proxy service #250

Closed mjgiarlo closed 1 year ago

mjgiarlo commented 1 year ago

Why was this change made? 🤔

This commit makes it easier for new users to begin using the SDR CLI by removing the manual step of needing to create a new user account in the SDR API. This accommodates a recent request to grant Tony C. access to the SDR API.

It also moves us incrementally closer to getting out of the business of managing custom accounts. It also ensures that users of SDR API have current, activated accounts in our institutional identity & access management system.

Includes:

New CLI UX

$ exe/sdr get druid:zz906pr0675 --url=https://sdr-api-stage.stanford.edu
I, [2022-12-13T14:57:26.187710 #1959418]  INFO -- : Retrieving metadata from: /v1/resources/druid:zz906pr0675
E, [2022-12-13T14:57:26.283247 #1959418] ERROR -- : There was an HTTP 401 error making the request: {"errors":"Signature has expired"
}
Token has expired! Please log in again.

$ exe/sdr login --url=https://sdr-api-stage.stanford.edu
Opened the configured authentication proxy in your browser. Once there, generate a new token and copy the entire value.
Opening in existing browser session.
Paste token here: {"token":"foo.bar.baz","exp":"12-14-2022 22:57"}
You are now authenticated for https://sdr-api-stage.stanford.edu until 12-14-2022 22:57

$ exe/sdr get druid:zz906pr0675 --url=https://sdr-api-stage.stanford.edu
I, [2022-12-13T14:59:29.178223 #1973029]  INFO -- : Retrieving metadata from: /v1/resources/druid:zz906pr0675
{"cocinaVersion":"0.73.6","type":"https://cocina.sul.stanford.edu/models/image","externalIdentifier":"druid:zz906pr0675","label":"api deposit attempt 20:51:28","version":8,"access":{"view":"world","download":"world","controlledDigitalLending":false,"copyright":"copyright wants to be perpetual 2/16","useAndReproductionStatement":"the defaults have changed again 2/16","license":"https://creativecommons.org/licenses/by/4.0/legalcode"},"administrative":{"hasAdminPolic...

How was this change tested? 🤨

CI + ran several operations against QA and stage with credentials in various states (logged in with current token, outdated token, missing credentials file, token from different env) + Andrew and I tested in stage