Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fredjens/auth0-sanity-poc
Authenticate with Auth0 and use Sanity for userdata
https://github.com/fredjens/auth0-sanity-poc
Last synced: 2 months ago
JSON representation
Authenticate with Auth0 and use Sanity for userdata
- Host: GitHub
- URL: https://github.com/fredjens/auth0-sanity-poc
- Owner: fredjens
- Created: 2019-08-30T14:47:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-04T18:16:54.000Z (about 5 years ago)
- Last Synced: 2024-05-15T10:41:19.294Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 795 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-sanity - Auth0 authentication and Sanity - Authenticate with Auth0 and use Sanity for userdata (Sample projects / How-to's)
README
# Auth0 and Sanity
_Proof of Concept_
- [Auth0](https://auth0.com) for authentication
- [Sanity](https://sanity.io) for user data##### Install
```
1. Add your own .env (from .env.examplef)
2. Add your Sanity credentials to sanity/sanity.json
3. yarn install
```##### Run
```
yarn dev 🚀
```## The flow
1. The frontend request login directly from Auth0.
2. The frontend reciews a callback containing the session token.
3. The frontend calls our backend using the session token.
4. The backend validates the token using the Auth0 API.
5. If the user is valid we search Sanity to find the user.
6. Return the userdata 🎉## Applications
### /frontend
The frontend is the [offical Auth0 react sample app](https://github.com/auth0-samples/auth0-react-samples/tree/master/01-Login). The only thing added is a hook that calls our `/backend` which again calls Sanity to get the user data.
### /backend
The backend is a Node/Express application, it has one route that take a request and returns the userdata is the user is authenticated correctly:
### /sanity
The Sanity config and Studio. We are using a private dataset for the userdata and an API key.