OneGraph / onegraph-changelog

Product Changelog for OneGraph using Persisted Queries

Home Page:https://onegraph.com/changelog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AuthGuardian support for TwitchTV & built-in values

sgrove opened this issue · comments

We've push support to AuthGuardian for rules based on the TwitchTV data: email rules, email verified, and login status.

That means you can build apps with TwitchTV login, and assign permissions basic on facts about them.

For example, to give users who have verified TwitchTV emails belonging to the onegraph.com domain admin access to our Hasura API, we can build these rules:

When this user on Twitchhas an email that has a domain that is equal to case insensitively "onegraph.com"
and this user on Twitch has verified email is true

Then On hasura set default role "admin"

And if we want to use information from Twitch in our API or client-side app, we can add an additional rule:

When this user on Twitch login status is true

Then On hasura set user id built in value TWITCH_TV_USER_ID
and In the json set value at path user.email built in value TWITCH_TV_EMAIL
and In the json set value at path user.avatarUrl built in value TWITCH_TV_LOGO_URL

And in the end, we'll get a JWT for our API or app with a payload of:

{
  "iss": "OneGraph",
  "aud": "https://serve.onegraph.com/dashboard/app/00000000-0000-0000-0000-000000000000",
  "iat": 1579589206,
  "exp": 1579675606,
  "https://hasura.io/jwt/claims": {
    "x-hasura-default-role": "admin",
    "x-hasura-allowed-roles": [
      "admin"
    ],
    "x-hasura-user-id": "258615874"
  },
  "user": {
    "email": "sean.s.grove+twitchtv@gmail.com",
    "avatarUrl": "https://static-cdn.jtvnw.net/jtv_user_pictures/8bacc874-0d33-40a2-9a2b-7827d4e94e2b-profile_image-300x300.png"
  }
}