-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the auth-token event name and document how it works (#360)
Update the auth-token event name and document how it works
- Loading branch information
Showing
11 changed files
with
153 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
"trailingComma": "es5", | ||
"proseWrap": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: Auth token provider | ||
path: /advanced/authentication | ||
--- | ||
|
||
# Authenticate users | ||
|
||
To allow a user to access data locked (🔒) behind authentication, the `manifold-auth-token` | ||
component can be used. The component will render the | ||
[shadowcat](https://github.com/manifoldco/shadowcat) authentication iframe and attempt to log in the | ||
currently logged in user for your platform using OAuth. See the shadowcat documentation for more | ||
information. | ||
|
||
```html | ||
<manifold-auth-token></manifold-auth-token> | ||
``` | ||
|
||
The component can be placed anywhere in the DOM tree as long as it exists within a | ||
`<manifold-connection>` component. | ||
|
||
## Receiving the token | ||
|
||
The component makes no decision as to how you should save the token on your side. As such, when the | ||
token is received from the iframe, an event is triggered that will give you the token. The token | ||
will be stored in the connection for use in subsequent API requests, but this event gives you the | ||
opportunity to save the token to prevent delays on the next page load as described in **Setting the | ||
cached token**. | ||
|
||
```js | ||
document.addEventListener('manifold-token-receive', ({ detail: { token } }) => { | ||
// create a cookie or localstorage value with the token | ||
}); | ||
``` | ||
|
||
## Setting the cached token | ||
|
||
The component can receive a token previously saved from an OAuth request to speed up all requests | ||
made by our components. If this token is provided, the OAuth request will still happen in order to | ||
refresh the token, but any fetch calls happening in our web components will not wait for that OAuth | ||
request to finish. | ||
|
||
```html | ||
<manifold-auth-token token="new-token"></manifold-auth-token> | ||
``` | ||
|
||
## Invalid token | ||
|
||
If the token given to the component is invalid, endpoints will return a 401 error and the token will | ||
be removed from the `manifold-connection`. Use the [error handling capabilities](/advanced/errors) | ||
of our web components to detect and act on such errors. | ||
|
||
## Authenticated requests timeout | ||
|
||
Any requests requiring authentication - which are sent by components locked (🔒) behind | ||
authentication - will wait on a valid token for up to 15 seconds. If this component does not inject | ||
a token into the connection after that time, an authentication error will be thrown. | ||
|
||
This timeout duration can be customized on the `manifold-connection` component. | ||
|
||
```html | ||
<manifold-connection wait-time="time-in-ms"> | ||
<!-- Application --> | ||
</manifold-connection> | ||
``` | ||
|
||
## Token expiration | ||
|
||
The token's expiration is encoded in the token string that the `manifold-token-receive` gives you. | ||
If the token is set as expired, it will automatically be refreshed with a new token using the | ||
shadowcat OAuth iframe. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3f8e2f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://ui-fgjx7magy.now.sh to the following aliases: