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

fix(GraphQl): Panic fix when subscription expiry is not present in jwt. #6129

Merged
merged 5 commits into from
Aug 7, 2020

Conversation

JatinDev543
Copy link
Contributor

@JatinDev543 JatinDev543 commented Aug 4, 2020

This PR fixes panic error when expiry is not given in jwt for subscriptions using authorization.


This change is Reviewable

@github-actions github-actions bot added the area/graphql Issues related to GraphQL support on Dgraph. label Aug 4, 2020
Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: we should add an automated test as well for when expiry is nil

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jatindevdg and @MichaelJCompton)


graphql/web/http.go, line 156 at r1 (raw file):

	}

	if len(header) == 0 || customClaims.StandardClaims.ExpiresAt == nil {

Do you need the if len(header) == 0 check here? Seems like only the second check is enough.

Also, add a comment here that for cases where no Header was given or for when expiry is nil we set to the zero value for time.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have we committed the main file here?

Reviewed 4 of 4 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jatindevdg, @manishrjain, @MichaelJCompton, and @vvbalaji-dgraph)


graphql/e2e/subscription/subscription_test.go, line 503 at r2 (raw file):

		string(resp.Data))

	// Add a TODO for alice which should not be visible in the update because JWT belongs to

You don't need anything below, do you? If the first query above worked then you have tested the fix right? Try to keep the tests as minimal as possible to test only what is required.


graphql/web/http.go, line 155 at r2 (raw file):

		}
	}
	//for the cases when no expiry is given in jwt or subscription doesn't have any authorization,

Add a space after // please.

Copy link
Contributor Author

@JatinDev543 JatinDev543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 3 files reviewed, 3 unresolved discussions (waiting on @manishrjain, @MichaelJCompton, @pawanrawal, and @vvbalaji-dgraph)


graphql/e2e/subscription/subscription_test.go, line 503 at r2 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

You don't need anything below, do you? If the first query above worked then you have tested the fix right? Try to keep the tests as minimal as possible to test only what is required.

yeah, deleted extra thing. i was just making sure auth is working correctly after this change.


graphql/web/http.go, line 156 at r1 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Do you need the if len(header) == 0 check here? Seems like only the second check is enough.

Also, add a comment here that for cases where no Header was given or for when expiry is nil we set to the zero value for time.

changed and added comment.


graphql/web/http.go, line 155 at r2 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Add a space after // please.

done.

@JatinDev543
Copy link
Contributor Author

Why have we committed the main file here?

sorry, it was by mistake.

Reviewed 4 of 4 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jatindevdg, @manishrjain, @MichaelJCompton, and @vvbalaji-dgraph)

graphql/e2e/subscription/subscription_test.go, line 503 at r2 (raw file):

		string(resp.Data))

	// Add a TODO for alice which should not be visible in the update because JWT belongs to

You don't need anything below, do you? If the first query above worked then you have tested the fix right? Try to keep the tests as minimal as possible to test only what is required.

graphql/web/http.go, line 155 at r2 (raw file):

		}
	}
	//for the cases when no expiry is given in jwt or subscription doesn't have any authorization,

Add a space after // please.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm

Reviewed 2 of 3 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jatindevdg, @manishrjain, @MichaelJCompton, and @vvbalaji-dgraph)


graphql/e2e/subscription/subscription_test.go, line 503 at r2 (raw file):

Previously, JatinDevDG (Jatin Dev) wrote…

yeah, deleted extra thing. i was just making sure auth is working correctly after this change.

That would already be taken care by the tests that we have already I think.

@JatinDev543
Copy link
Contributor Author

:lgtm

Reviewed 2 of 3 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @jatindevdg, @manishrjain, @MichaelJCompton, and @vvbalaji-dgraph)

graphql/e2e/subscription/subscription_test.go, line 503 at r2 (raw file):

Previously, JatinDevDG (Jatin Dev) wrote…

yeah, deleted extra thing. i was just making sure auth is working correctly after this change.

That would already be taken care by the tests that we have already I think.

yeah.

@JatinDev543 JatinDev543 merged commit 37823e9 into master Aug 7, 2020
@JatinDev543 JatinDev543 deleted the jatin/subscriptionAuth-withoutExpiryPanic-fix branch August 7, 2020 09:42
JatinDev543 added a commit that referenced this pull request Aug 13, 2020
…t. (#6129)

This PR fixes panic error when expiry is not given in jwt for subscriptions using authorization.

(cherry picked from commit 37823e9)
JatinDev543 added a commit that referenced this pull request Aug 13, 2020
…t. (#6129) (#6175)

This PR fixes panic error when expiry is not given in jwt for subscriptions using authorization.

(cherry picked from commit 37823e9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph.
Development

Successfully merging this pull request may close these issues.

2 participants