All Projects → LawJolla → Prisma Auth0 Example

LawJolla / Prisma Auth0 Example

Licence: mit
Boilerplate Prisma Startup

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Prisma Auth0 Example

Pizzaql
🍕 Modern OSS Order Management System for Pizza Restaurants
Stars: ✭ 631 (+242.93%)
Mutual labels:  graphql, prisma, auth0
Nextjs Hasura Boilerplate
🎨 Boilerplate for building applications using Hasura and Next.js
Stars: ✭ 126 (-31.52%)
Mutual labels:  graphql, apollo-client
Fakebooker Frontend
Stars: ✭ 124 (-32.61%)
Mutual labels:  graphql, apollo-client
Prisma Examples
🚀 Ready-to-run Prisma example projects
Stars: ✭ 3,017 (+1539.67%)
Mutual labels:  graphql, prisma
Nextjs Headless Wordpress
🔥 Nextjs Headless WordPress
Stars: ✭ 110 (-40.22%)
Mutual labels:  graphql, apollo-client
Graphql Codegen Hasura
code-generator plugins for hasura/apollo-gql/typescript development
Stars: ✭ 113 (-38.59%)
Mutual labels:  graphql, apollo-client
Awesome Apollo Graphql
A curated list of amazingly awesome things regarding Apollo GraphQL ecosystem 🌟
Stars: ✭ 126 (-31.52%)
Mutual labels:  graphql, apollo-client
Relay Northwind App
A complex React, Relay, GraphQL demo app. Online demo:
Stars: ✭ 104 (-43.48%)
Mutual labels:  graphql, demo
Typegraphql Prisma
Prisma 2 generator to emit TypeGraphQL types and CRUD resolvers from your Prisma 2 schema
Stars: ✭ 137 (-25.54%)
Mutual labels:  graphql, prisma
Ra Data Opencrud
A react-admin data provider for Prisma and GraphCMS
Stars: ✭ 142 (-22.83%)
Mutual labels:  graphql, prisma
Graphql Directive
Use custom directives in your GraphQL schema and queries 🎩
Stars: ✭ 142 (-22.83%)
Mutual labels:  graphql, apollo-client
Apollo Cache Redux
Redux cache for Apollo Client 2.0. This project is no longer maintained.
Stars: ✭ 179 (-2.72%)
Mutual labels:  graphql, apollo-client
Apollo Link
🔗 Interface for fetching and modifying control flow of GraphQL requests
Stars: ✭ 1,434 (+679.35%)
Mutual labels:  graphql, apollo-client
React Graphql Github Apollo
🚀 A React + Apollo + GraphQL GitHub Client. Your opportunity to learn about these technologies in a real world application.
Stars: ✭ 1,563 (+749.46%)
Mutual labels:  graphql, apollo-client
Angular1 Apollo
AngularJS integration for the Apollo Client
Stars: ✭ 108 (-41.3%)
Mutual labels:  graphql, apollo-client
Serverless Prisma
AWS Serverless Prisma Boilerplate
Stars: ✭ 126 (-31.52%)
Mutual labels:  graphql, prisma
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+896.2%)
Mutual labels:  graphql, apollo-client
Production Ready Expressjs Server
Express.js server that implements production-ready error handling and logging following latest best practices.
Stars: ✭ 101 (-45.11%)
Mutual labels:  graphql, prisma
Guide
📖 The GraphQL Guide website
Stars: ✭ 104 (-43.48%)
Mutual labels:  graphql, apollo-client
React Redux Graphql Apollo Bootstrap Webpack Starter
react js + redux + graphQL + Apollo + react router + hot reload + devTools + bootstrap + webpack starter
Stars: ✭ 127 (-30.98%)
Mutual labels:  graphql, apollo-client

Prisma React Auth0 Example

Video Demo

🚀 Basic starter code for a fullstack app based on Prisma, Auth0, React, GraphQL & Apollo Client.

Goals

My idea of a possible authentication and authorization flow for Prisma's Instagram (blog?) clone. I am not an expert and put together this repo as a learning exercise.

This repo follows the Prisma Permissions.

If you see any potential security issues, please let me know!

Technologies

  • Frontend
    • React: Frontend framework for building user interfaces
    • Apollo Client: Fully-featured, production ready caching GraphQL client
  • Backend
    • Auth0: Authentication as a service. (And this demo uses RS256 hotness!)
    • Prisma: Turns your database into a GraphQL API
    • graphql-yoga: Fully-featured GraphQL server with focus on easy setup, performance & great developer experience
    • prisma-binding: GraphQL binding for Prisma services

Requirements

You need to have the following things installed:

  • Git
  • Node 8+
  • Prisma CLI: npm i -g prisma
  • Auth0 account
  • Basic Auth0 Console Knowledge -- this demo is short on how to configure the Auth0 console, but even a novice Auth0 user should get it. I did! This is my first project using Auth0.

Getting started

# 1. Clone it
git clone [email protected]:LawJolla/prisma-auth0-example.git

# 2. Navigate into the folder
cd prisma-auth0-example

#3 Install dependencies.  NPM should work if not using yarn
yarn install

#4 Install server dependencies
cd server
yarn install

#5 Make .env file
touch .env

#6 open .env in your editor of choice, e.g.
code .env

Make your prisma secret PRISMA_SECRET="myapp123"


#7 Deploy Prisma cluster
prisma deploy

#8 Copy HTTP endpoint from Prisma, e.g. https://us1.prisma.sh... or localhost...

.env file

Your .env now file now also needs the following:

PRISMA_ENDPOINT="YOUR_COPIED_ENDPOINT" # e.g. https://us1-prisma.sh...
AUTH0_DOMAIN="YOUR_AUTHO_DOMAN" # e.g. yourdomain.auth0.com
AUTH0_AUDIENCE="YOUR_API/AUDIENCE" # e.g. https://yourdomain.auth0.com/api/v2/
AUTH0_ISSUER="https://YOUR_AUTH0_DOMAIN" # e.g. https://yourdomain.auth0.com/

Your Auth0 console will provided the needed information above.

Make sure your audience is an API and not https://...auth0.com/userinfo. That will not return an access token. Only an API will.

#8 Start the server
yarn dev

#9 Configure your client Auth0 variables
cd ..
cd src/auth

#10 Create an auth0-variables file
touch auth0-variables

#11 Edit auth0-variables.js in your favorite editor, e.g.
code auth0-variables

auth0-variables.js

Copy and paste the AUTH_CONFIG below, and fill in the variables, and save

export const AUTH_CONFIG = {
  api_audience: 'YOUR_API_AUDIENCE`, #same as above in server
  domain: 'YOUR_DOMAIN', // e.g. your-domain.auth0.com
  clientId: 'YOUR_CLIENT_ID', // e.g. string of characters from Auth0 for your API
  callbackUrl: "http://localhost:8000/callback" // make sure Auth0 has http://localhost:8000 as a callback url
}
#11 Start the client
yarn start

#12 Navigate to localhost:8000

#13 See what errors you get 🤣

#Directive Permissions

This demo uses the new-ish GraphQL directive permission pattern. Here's a great video from Ryan Chenkie, a developer at Auth0, describing how it works.

Tl;dr: Simply decorate your fields / queries / mutations with directives, and let the directive resolvers handle the rest!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].