# Does @withSubscription not work yet with @auth rules?

**URL:** <https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901>\
**Category:** GraphQL\
**Tags:** kind:question, auth, subscription\
**Created:** [July 21, 2020, 3:39pm UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901 "2020-07-21T15:39:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [July 21, 2020, 3:39pm UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/1 "2020-07-21T15:39:04Z")

</div>

> _Sidenote, we probably need a subscription tag too in Discuss._

Saw the [blog on Subscriptions](http://discuss.hypermode.com/t/how-graphql-subscriptions-work-dgraph-blog/8894) today and was excited to give it a run for the money!

With a simple scheme it worked perfectly

```auto
type Message @withSubscription {
  id: ID!
  to: String!
  from: String!
  message: String!
}

```

However I need to also secure these so users only see their own messages of course, so just a simple test with the @auth directive fails.

```auto
type Message @withSubscription @auth(
  query: { rule: "{$USERROLE: { eq: \"USER\"}}" }
) {
  id: ID!
  to: String!
  from: String!
  message: String!
}
# Dgraph.Authorization {"VerificationKey":"super-secret","Header":"auth","Namespace":"https://mydomain.com/jwt/claims","Algo":"HS256"}

```

example header:

```auto
{ "auth":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1OTIyMzkwMjIsImV4cCI6MTU5NzIzOTAyMiwiaHR0cHM6Ly9teWRvbWFpbi5jb20vand0L2NsYWltcyI6eyJVU0VSUk9MRSI6IlVTRVIifX0.pU61zHMOaz1ZJ7GCvJsHIRqKSwZe4RI5TVZywkaqkXM" }

```

Now this works for the basic query but with a subscription it just returns an empty data set, acts like it has not authority

* * *

Subscriptions are going to be pretty useless to me until they also work with auth rules. Maybe I am missing an auth rule for `subscriptions`? but seeing that a subscription is the same as a query I would think it would work with the same query rules.

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [July 21, 2020, 5:25pm UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/2 "2020-07-21T17:25:56Z")

</div>

Which version of Dgraph are you using ?  
Subscription with auth rules are pushed to master yesterday only!! and have to wait untill we push it into release.  
You can try it on master branch untill then.  
@pawan any idea when auth+subscriptions will be avaliable on release ?

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [July 21, 2020, 6:01pm UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/3 "2020-07-21T18:01:04Z")

</div>

I was using standalone:master not sure how recent though, within the week. I will see if there is a newer image. And I can wait a little bit longer. I just jumped the gun

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [July 22, 2020, 7:16am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/4 "2020-07-22T07:16:13Z")

</div>

This should be available on the [latest master image](https://hub.docker.com/layers/dgraph/dgraph/master/images/sha256-35c8c057dc9d4d6b31dad028946eaa981d1b37e66df168c4fbb425d794d2ab35?context=explore) and also the [standalone image](https://hub.docker.com/layers/dgraph/standalone/master/images/sha256-dcc3ea0894dcb112d01e6b2dbc576187be6c9bc85c14d97b7cda4add9a946528?context=explore). Unfortunately it won’t make it to `20.07.0` which goes out next week. We plan to push it out as part of `20.07.1` which goes out next month.

---

<div class="post-metadata">

**Author:** ![timcash](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/timcash/32/4450_2.png) [@timcash](https://discuss.dgraph.io/u/timcash)\
**Post date:** [August 26, 2020, 12:06am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/5 "2020-08-26T00:06:24Z")

</div>

Did this make it in? Also trying to use subscription and auth like so

```auto
type Nex @withSubscription @auth(
    query: { rule: "{ $isAuth: { eq: \"true\" } }"}
) {
    title: String! @id
}

```

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [August 26, 2020, 12:27am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/6 "2020-08-26T00:27:43Z")

</div>

> [@amaster507](#):
>
> Sidenote, we probably need a subscription tag too in Discuss.

And done 🙂

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [August 26, 2020, 1:08am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/7 "2020-08-26T01:08:36Z")

</div>

It should. I have not retested it since released.

---

<div class="post-metadata">

**Author:** ![timcash](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/timcash/32/4450_2.png) [@timcash](https://discuss.dgraph.io/u/timcash)\
**Post date:** [August 26, 2020, 4:25am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/8 "2020-08-26T04:25:07Z")

</div>

Sorry I mean the feature to combine the two @auth and @withSubscription

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [August 26, 2020, 5:37am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/9 "2020-08-26T05:37:45Z")

</div>

Yes, thats available on Slash GraphQL and also master, 20.07.1 release.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [August 28, 2020, 12:45am UTC](https://discuss.dgraph.io/t/does-withsubscription-not-work-yet-with-auth-rules/8901/10 "2020-08-28T00:45:04Z")

</div>

Split this topic on August 28, 2020, 12:45am UTC

3 posts were split to a new topic: [Auth and Subscription How To](https://discuss.dgraph.io/t/auth-and-subscription-how-to/9711)
