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:
Use the config gem (only in the CLI code) for mapping SDR API URLs onto authentication proxy URLs (currently this is Argo but needn't stay in Argo forever)
Stop requiring the CLI code in the entrypoint to the gem, and require it instead in the exe/sdr script
Ditch explicit SdrClient:: scoping in the CLI class, as it's unnecessary
Add a new TokenFailed exception to allow user-friendlier CLI messages
Wrap all CLI operations in the same block checking for a valid token
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
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:
exe/sdr
scriptSdrClient::
scoping in the CLI class, as it's unnecessaryNew CLI UX
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