• Stars
    star
    362
  • Rank 116,840 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GraphQL Auth with JSON Web Tokens

This repo demonstrates some ways you might build authentication and authorization logic into your GraphQL API. GraphQL itself does not prescribe any particular way to do auth and those details are left up to the developer.

The approaches here may or may not be suitable for your own implementation.

JSON Web Tokens

This GraphQL server uses JSON Web Tokens (JWT) for authorization. You will need some tokens to begin with to test the API. Here are a few you can use:

JWT With No Scope

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJncmFwaHFsLXRlc3Qtc2VydmVyIiwiaWF0IjoxNTA5MDQxMTE3LCJleHAiOjE1NDA1NzcxMTcsImF1ZCI6ImdyYXBocWwtdGVzdC1hcGkiLCJzdWIiOiIxMjMifQ.tTRbNKT58UqRMqMkf8cLenRZ0qvf15mUl6N6dWyn_Wo

JWT With write:articles Scope

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJncmFwaHFsLXRlc3Qtc2VydmVyIiwiaWF0IjoxNTA5MDQxMTE3LCJleHAiOjE1NDA1NzcxMTcsImF1ZCI6ImdyYXBocWwtdGVzdC1hcGkiLCJzdWIiOiIxMjMiLCJzY29wZSI6IndyaXRlOmFydGljbGVzIn0.mupYodqVggdF1fZaiyVdfOGLwY_R3KISGBTCJ7hhH5U

The sub claim in these tokens is 123 which maps to the same author ID in the supplied data.

The secret key for these tokens is found in the .env file. THIS SECRET KEY IS TERRIBLY WEAK, DO NOT USE IT IN PRODUCTION.

To test the API, attach one of the tokens to the Authorization header in your requests using the Bearer scheme. For example:

Authorization: Bearer eyJ0...

License

MIT

More Repositories

1

orbit

CSS
200
star
2

react-user-authentication

JavaScript
126
star
3

vue-events-bulletin

Code for the Scotch.io Vue.js tutorial
JavaScript
87
star
4

vue-node-time-tracker

JavaScript
73
star
5

user-authentication-api

JavaScript
66
star
6

jot-bot

Token-Based Authentication for AngularJS and Laravel Tutorial
PHP
54
star
7

next-prisma

TypeScript
51
star
8

ng2-cribs

TypeScript
30
star
9

angular2-user-authentication

TypeScript
29
star
10

next-prisma-ecommerce

TypeScript
28
star
11

socialcue

TypeScript
27
star
12

aurelia-jwt-auth

JavaScript
25
star
13

angular-cli-heroku

TypeScript
23
star
14

fem-instructors-api

API for Front End Masters Hapi.js Workshop
JavaScript
21
star
15

ngclassifieds

HTML
18
star
16

angular-auth

TypeScript
17
star
17

shirt-shop

TypeScript
16
star
18

prisma-ecommerce

TypeScript
14
star
19

graphql-server

GraphQL Server for Front End Masters' GraphQL Workshop
JavaScript
14
star
20

fem-instructors-app

Client side app for Front End Masters Hapi.js Workshop
TypeScript
13
star
21

auth0-graphql

CSS
11
star
22

try-graphql

CSS
10
star
23

custom-operators-workshop

RxJS Custom Operators Workshop for ng-conf 2018
TypeScript
9
star
24

reactathon-security-workshop

8
star
25

orbit-graphql

CSS
8
star
26

angular1-user-authentication

JavaScript
8
star
27

angular-coordinates

Code for the AngularJS Custom Filter tutorial at ryanchenkie.com/angularjs-custom-filter
JavaScript
5
star
28

egghead-react-auth-workshop

4
star
29

casino-api

TypeScript
3
star
30

thisdot-prisma

TypeScript
3
star
31

chenkie.github.io

HTML
2
star
32

angular-laravel-typeahead

Simple Typeahead with AngularJS and Laravel
PHP
2
star
33

formly-car-rental

Code for the Angular-Formly Tutorial on Scotch.io
JavaScript
2
star
34

fire-status

Code of the AngularJS + Firebase Tutorial on Sitepoint
JavaScript
2
star
35

electron-auth0-quickstart

JavaScript
2
star
36

silent-authentication

TypeScript
2
star
37

dinos-dragons-graphql

JavaScript
1
star
38

contacts-app

CSS
1
star
39

orbit-nexus

CSS
1
star
40

react-graphql-auth

JavaScript
1
star
41

ng-cribs

Code for the tutorial at ryanchenkie.com
HTML
1
star
42

enterprise-ng

TypeScript
1
star
43

material-contact-form

TypeScript
1
star
44

ottawa-js-jwt

JavaScript
1
star
45

mission-control-csa

JavaScript
1
star
46

vue-github-users

Code for SitePoint Vue.js Article
Vue
1
star