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 http verb #4299

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-http-verb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix HTTP verb of the generate-invite endpoint

We changed the HTTP verb of the /generate-invite endpoint of the sciencemesh
service to POST as it clearly has side effects for the system, it's not just a
read-only call.

https://github.com/cs3org/reva/pull/4299
2 changes: 1 addition & 1 deletion internal/http/services/sciencemesh/sciencemesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (s *svc) routerInit() error {
return err
}

s.router.Get("/generate-invite", tokenHandler.Generate)
s.router.Post("/generate-invite", tokenHandler.Generate)
s.router.Get("/list-invite", tokenHandler.ListInvite)
s.router.Post("/accept-invite", tokenHandler.AcceptInvite)
s.router.Get("/find-accepted-users", tokenHandler.FindAccepted)
Expand Down
6 changes: 5 additions & 1 deletion pkg/ocm/provider/authorizer/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ func (a *authorizer) IsProviderAllowed(ctx context.Context, pi *ocmprovider.Prov
if hostIPs, ok := a.providerIPs.Load(ocmHost); ok {
ipList = hostIPs.([]string)
} else {
addr, err := net.LookupIP(ocmHost)
host, _, err := net.SplitHostPort(ocmHost)
if err != nil {
return errors.Wrap(err, "json: error looking up client IP")
}
addr, err := net.LookupIP(host)
if err != nil {
return errors.Wrap(err, "json: error looking up client IP")
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/grpc/ocm_invitation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ var _ = Describe("ocm invitation workflow", func() {
}

generateToken := func(revaToken, domain string) (*generateInviteResponse, int) {
req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, fmt.Sprintf("http://%s/sciencemesh/generate-invite", domain), nil)
req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost, fmt.Sprintf("http://%s/sciencemesh/generate-invite", domain), nil)
Expect(err).ToNot(HaveOccurred())
req.Header.Set("x-access-token", revaToken)

Expand Down
Loading