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

NOVER-5: add authz http mw #31

Closed

Conversation

cbarik-infoblox
Copy link

The http_opa package contains the new http middleware implementation for authorising http requests.
Most of the public methods/functions/interfaces have been copied from the grpc_opa package to allow for backward compatibility.
Some of the util functions have been moved to common folder to be reused by grpc and http and yet a stub file has been created to avoid build issues for the existing consumers.

For the opa client, it expects a jwt token in the Authorization header, prefixed with Bearer and an optional X-Request-ID header.

Unauthorised requests will usually be rejected with a status of 401 Unauthorized

Comment on lines 23 to 25
if len(newBearerErrorList) > 0 || len(bearerErrorList) > 0 {
//fishy Should not have multiple newBearers
}
Copy link

Choose a reason for hiding this comment

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

Add a TODO for checks. Do not remove.

go.mod Outdated
Comment on lines 19 to 22
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.1.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Copy link

Choose a reason for hiding this comment

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

are these new packages required for http middleware ?

Copy link
Author

Choose a reason for hiding this comment

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

out.txt
this is the graph file for the dependencies, as per the file, these might have been introduced due to go.uber.org/multierr or github.com/stretchr/testify. Middleware is using these libraries

Copy link
Contributor

Choose a reason for hiding this comment

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

this is middleware, lets use standard go libraries.

Copy link
Author

Choose a reason for hiding this comment

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

@kumaya kumaya requested a review from drewwells February 5, 2024 09:23
Comment on lines 180 to 193
defer func() {
span.SetStatus(trace.Status{
Code: int32(grpc.Code(err)),
Message: grpc.ErrorDesc(err),
})
span.End()
logger.WithFields(log.Fields{
"opaResp": opaResp,
"elapsed": time.Since(now),
}).Debug("authorization_result")
}()
if err != nil {
return false, ctx, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would comment out these traces, and remove references to grpc. http_opa shouldn't require any version of grpc. Commenting out the traces will also remove the dependence on opentracing found in here. Maybe we should publish http_opa as a separate module too... so people aren't bound to the grpc version being imported in other parts of atlas-authz-middleware.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure we want to remove the opentracing? Wasn't there a requirement to add them?

Copy link

Choose a reason for hiding this comment

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

@cbarik-infoblox Please remove grpc related dependencies from http middleware. While we would need tracing for http; add a TODO and work towards getting the initial functionality.

@rchowinfoblox
Copy link
Collaborator

@cbarik-infoblox you mention "Most of the public methods/functions/interfaces have been copied". I'm not what you mean by this. My concern if there is ANY public method/function/interface/type/variable/constant/whatever that has been removed, it may break backwards compatibility.

@cbarik-infoblox
Copy link
Author

@cbarik-infoblox you mention "Most of the public methods/functions/interfaces have been copied". I'm not what you mean by this. My concern if there is ANY public method/function/interface/type/variable/constant/whatever that has been removed, it may break backwards compatibility.

@rchowinfoblox when I said copied, I meant that the new package http_opa is created by taking most of the functionalities from the existing package grpc_opa while keeping the latter intact. Whatever has been moved out of grpc_opa is compensated by creating the stub inside the same package. Hope this clarifies

@kumaya
Copy link

kumaya commented Feb 6, 2024

My concern if there is ANY public method/function/interface/type/variable/constant/whatever that has been removed, it may break backwards compatibility

What is your suggestion, @rchowinfoblox ? Shouldn't the current test cases be capable of detecting those issues?

@rchowinfoblox
Copy link
Collaborator

What is your suggestion, @rchowinfoblox ? Shouldn't the current test cases be capable of detecting those issues?

I'm not sure our current test cases provide 100% coverage. Anyways I'm good with @cbarik-infoblox 's reply above.

@cbarik-infoblox cbarik-infoblox deleted the NOVER-5_authz_http_mw branch February 8, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants