Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to set a shareId #267

Merged
merged 14 commits into from
May 7, 2020

Conversation

anthony-j-castro
Copy link
Contributor

@anthony-j-castro anthony-j-castro commented May 4, 2020

We recently ran into an issue where some requests on private share link pages would fail because we were only allowing a single accessToken. For these share links, accessToken was being set to the share ID, and the authentication header would never get configured.

This PR adds a separate shareId option that can be set in addition to the accessToken, allowing both headers to exist on a request.

@anthony-j-castro anthony-j-castro marked this pull request as draft May 4, 2020 23:06
@anthony-j-castro
Copy link
Contributor Author

anthony-j-castro commented May 4, 2020

@amccloud this is still a WIP but I wanted to get your opinion on this approach before I finish things up with tests and documentation (and having to change some things after #266 is merged).

Edit: I just came across SDK-386, which looks identical to what I'm trying to do here 😅 I can change shareToken to shareId like in the ticket, that definitely makes more sense.

Copy link
Contributor

@amccloud amccloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anthony-j-castro yup, this is another version of https://goabstract.atlassian.net/browse/SDK-386

I think we should just update Client to support both authentication options and update Endpoint to send both when it has both

src/endpoints/Endpoint.js Outdated Show resolved Hide resolved
@anthony-j-castro
Copy link
Contributor Author

@amccloud is this on the right track? I removed the ability for accessToken to accept a share value--now it has to be explicitly sent in as shareId.

Copy link
Contributor

@amccloud amccloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anthony-j-castro lgtm 👍

You can create a tagged pre-release to start to test this PR with UI (or possibly just link locally)

tests/Client.test.js Outdated Show resolved Hide resolved
src/endpoints/Endpoint.js Outdated Show resolved Hide resolved
src/types.js Outdated Show resolved Hide resolved
@anthony-j-castro anthony-j-castro changed the title feat: Add ability to set a shareToken feat: Add ability to set a shareId May 6, 2020
const tokenHeader =
typeof token === "string"
? { Authorization: `Bearer ${token}` }
: { "Abstract-Share-Id": token && inferShareId(token) };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're removing the ability to pass a share ID as an accessToken. Technically this would be a breaking change, but it's not documented for the public and I'm going to update our only usage in ui after a prerelease is cut.

@anthony-j-castro anthony-j-castro marked this pull request as ready for review May 6, 2020 18:51
@anthony-j-castro
Copy link
Contributor Author

@amccloud I've been testing this locally using a linked version and it's working well 👍

src/types.js Outdated Show resolved Hide resolved
Copy link
Contributor

@amccloud amccloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Just two last things before this is ready:

src/types.js Outdated Show resolved Hide resolved
Comment on lines +44 to +47
### `shareId`

This option can be used to pass a share identifier (`string`, [`ShareDescriptor`](/docs/abstract-api/#sharedescriptor), or [`ShareUrlDescriptor`](/docs/abstract-api/#shareurldescriptor)) to access objects associated with a public [share](/docs/abstract-api/#shares) without having to authenticate with an `accessToken`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amccloud here's my first attempt at documenting. Suggestions are welcome 🙃

@berezovskyicom berezovskyicom merged commit 23f9ed0 into master May 7, 2020
@berezovskyicom berezovskyicom deleted the allow-share-and-auth-tokens branch May 7, 2020 13:10
@berezovskyicom berezovskyicom restored the allow-share-and-auth-tokens branch May 7, 2020 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants