Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthGuardian support for TwitchTV & built-in values #41

Open
sgrove opened this issue Jan 21, 2020 · 0 comments
Open

AuthGuardian support for TwitchTV & built-in values #41

sgrove opened this issue Jan 21, 2020 · 0 comments

Comments

@sgrove
Copy link

sgrove commented Jan 21, 2020

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": "[email protected]",
    "avatarUrl": "https://static-cdn.jtvnw.net/jtv_user_pictures/8bacc874-0d33-40a2-9a2b-7827d4e94e2b-profile_image-300x300.png"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant