Skip to content

Commit

Permalink
Merge pull request #4299 from aduffeck/fix-http-verb
Browse files Browse the repository at this point in the history
Fix http verb
  • Loading branch information
aduffeck authored Nov 6, 2023
2 parents 6162d96 + d6a2685 commit d3831fd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
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

0 comments on commit d3831fd

Please sign in to comment.