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

feat: add dynamic cors support #6174

Merged
merged 24 commits into from
Aug 25, 2020
Merged

feat: add dynamic cors support #6174

merged 24 commits into from
Aug 25, 2020

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Aug 13, 2020

Signed-off-by: பாலாஜி balaji@dgraph.io


This change is Reviewable

Docs Preview: Dgraph Preview

Signed-off-by: பாலாஜி <balaji@dgraph.io>
@github-actions github-actions bot added area/graphql Issues related to GraphQL support on Dgraph. area/schema Issues related to the schema language and capabilities. labels Aug 13, 2020
@poonai poonai changed the title feat: add dynamic cors support feat: wip add dynamic cors support Aug 13, 2020
@poonai poonai requested a review from gja August 13, 2020 09:01
poonai and others added 12 commits August 13, 2020 10:35
Signed-off-by: Balaji <rbalajis25@gmail.com>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
add list based schema

Signed-off-by: Balaji <rbalajis25@gmail.com>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: Balaji <rbalajis25@gmail.com>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
…aji/cors

Signed-off-by: Balaji <rbalajis25@gmail.com>
Signed-off-by: Balaji <rbalajis25@gmail.com>
Signed-off-by: Balaji <rbalajis25@gmail.com>
@poonai poonai changed the title feat: wip add dynamic cors support feat: add dynamic cors support Aug 17, 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.

Mostly looking good, I'll approve. Just check and address the comments. Also, check with @gja about the behavior after DROP_ALL and DROP_DATA.

Reviewed 1 of 8 files at r1, 3 of 7 files at r2, 1 of 5 files at r4, 4 of 8 files at r6, 9 of 10 files at r7, 9 of 9 files at r8.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @balajijinnah, @gja, @manishrjain, @MichaelJCompton, and @vvbalaji-dgraph)


edgraph/server.go, line 89 at r8 (raw file):

	// AuthorizeCors is used to indicate that the given request is authorized to do
	// cors mutation.
	AuthorizeCors

CorsMutationAllowed


edgraph/server.go, line 357 at r8 (raw file):

		// recreate the admin account after a drop data operation
		ResetAcl()
		ResetCors()

Should not be dropped on DROP_ALL and DROP_DATA


edgraph/server.go, line 1224 at r8 (raw file):

}

func authorizeCors(ctx context.Context, qc *queryContext) error {

validateCorsInMutation


edgraph/server.go, line 1621 at r8 (raw file):

	}
	corsRes := &corsResponse{}
	fmt.Println(string(res.Json))

remove this


edgraph/server.go, line 1625 at r8 (raw file):

		return nil, err
	}
	//x.AssertTrue(len(corsRes.Me) == 1)

Print a glog.Error if len > 1


graphql/admin/cors.go, line 86 at r8 (raw file):

// arrayToInterface convers array string to array interface
func arrayToInterface(in []string) []interface{} {

rather than doing this fix it in completeObject in graphql/resolve/resolver.go


graphql/e2e/custom_logic/custom_logic_test.go, line 191 at r8 (raw file):

	result := params.ExecuteAsPost(t, alphaURL)
	if result.Errors != nil {

remove


graphql/e2e/normal/normal_test.go, line 214 at r8 (raw file):

			"list": true,
			"index": true,
      		"tokenizer": [

formatting is messed up


graphql/web/http.go, line 349 at r8 (raw file):

	w.Header().Set("Access-Control-Allow-Headers", x.AccessControlAllowedHeaders)
	w.Header().Set("Access-Control-Allow-Credentials", "true")
	w.Header().Set("Connection", "close")

this should be returned in all cases?

@gja
Copy link
Contributor

gja commented Aug 19, 2020

I think it's best if DROP_DATA retains this data. If it's possible and not something that takes forever to implement.

Also, could we rename the methods too include the word origins?

getAllowedCORSOrigins / replaceAllowedCORSOrigins. Then the body can be {origins: []}

பாலாஜி and others added 6 commits August 21, 2020 11:36
tmp
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: Balaji <rbalajis25@gmail.com>
பாலாஜி added 5 commits August 24, 2020 17:09
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
Signed-off-by: பாலாஜி <balaji@dgraph.io>
@poonai poonai merged commit 7820d71 into master Aug 25, 2020
@poonai poonai deleted the balaji/cors branch August 25, 2020 05:51
poonai added a commit that referenced this pull request Aug 25, 2020
poonai added a commit that referenced this pull request Aug 25, 2020
@manishrjain
Copy link
Contributor

This PR introduced a bunch of issues in which Alpha server would not shut down correctly, @pawanrawal .

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. area/schema Issues related to the schema language and capabilities.
Development

Successfully merging this pull request may close these issues.

4 participants