Closed eguzki closed 8 months ago
Attention: 66 lines
in your changes are missing coverage. Please review.
Comparison is base (
d3d31d0
) 0.42% compared to head (fdb047b
) 0.38%.
Files | Patch % | Lines |
---|---|---|
cmd/generate_kuadrant_authpolicy.go | 0.00% | 65 Missing :warning: |
cmd/generate_kuadrant.go | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
👀
seeing a panic - wondered if it was the spec, or something environmental.
kuadrantctl generate kuadrant authpolicy --oas ./openapi.yaml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x78 pc=0x1039eea74]
goroutine 1 [running]:
github.com/kuadrant/kuadrantctl/pkg/kuadrantapi.AuthPolicyAuthenticationSchemeFromOAS(0x140000be3f0)
/Users/jmadigan/Work/kuadrantctl/pkg/kuadrantapi/authpolicy.go:136 +0x344
github.com/kuadrant/kuadrantctl/cmd.buildAuthPolicy(0x140000be3f0?)
/Users/jmadigan/Work/kuadrantctl/cmd/generate_kuadrant_authpolicy.go:84 +0xa4
github.com/kuadrant/kuadrantctl/cmd.runGenerateKuadrantAuthPolicy(0x140002c3e00?, {0x103a257ca?, 0x4?, 0x103a257ce?})
/Users/jmadigan/Work/kuadrantctl/cmd/generate_kuadrant_authpolicy.go:56 +0xf0
github.com/spf13/cobra.(*Command).execute(0x14000400f00, {0x14000310180, 0x2, 0x2})
/Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940 +0x658
github.com/spf13/cobra.(*Command).ExecuteC(0x14000209800)
/Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(0x140001be130?)
/Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992 +0x1c
main.main()
/Users/jmadigan/Work/kuadrantctl/main.go:27 +0x58
spec: https://gist.github.com/jasonmadigan/6e1eae05423d7012a26eb0cc6a751b22
seeing a panic - wondered if it was the spec, or something environmental.
kuadrantctl generate kuadrant authpolicy --oas ./openapi.yaml panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x78 pc=0x1039eea74] goroutine 1 [running]: github.com/kuadrant/kuadrantctl/pkg/kuadrantapi.AuthPolicyAuthenticationSchemeFromOAS(0x140000be3f0) /Users/jmadigan/Work/kuadrantctl/pkg/kuadrantapi/authpolicy.go:136 +0x344 github.com/kuadrant/kuadrantctl/cmd.buildAuthPolicy(0x140000be3f0?) /Users/jmadigan/Work/kuadrantctl/cmd/generate_kuadrant_authpolicy.go:84 +0xa4 github.com/kuadrant/kuadrantctl/cmd.runGenerateKuadrantAuthPolicy(0x140002c3e00?, {0x103a257ca?, 0x4?, 0x103a257ce?}) /Users/jmadigan/Work/kuadrantctl/cmd/generate_kuadrant_authpolicy.go:56 +0xf0 github.com/spf13/cobra.(*Command).execute(0x14000400f00, {0x14000310180, 0x2, 0x2}) /Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940 +0x658 github.com/spf13/cobra.(*Command).ExecuteC(0x14000209800) /Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320 github.com/spf13/cobra.(*Command).Execute(0x140001be130?) /Users/jmadigan/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992 +0x1c main.main() /Users/jmadigan/Work/kuadrantctl/main.go:27 +0x58
spec: https://gist.github.com/jasonmadigan/6e1eae05423d7012a26eb0cc6a751b22
Ok, sorry about that. I fixed it.
However, even if your OAS is syntactically correct, it does not specify what you aim to represent. The GET /api/v3//store/inventory
is protected with the api_key
security scheme, and not with the intended secureDog
one. Kuadrant extensions x-kuadrant
does not define security
field. The tool reads security requriements from opeation's security field, not from the kuadrant extension security field.
Now, it should not panic, just return an authpolicy without rules.
Ran through the comprehensive steps (thank you for including) and this worked good
What
New command
kuadrantctl generate kuadrant authpolicy
to create kuadrant Auth Policy from OpenAPI Specification (OAS) 3.x powered with kuadrant extensionsopenIdConnect type
This initial version of the command only generates AuhPolicy when there is at least one security requirement referencing the Security Scheme Object which type is
openIdConnect
.Example
Running the command
The generated authpolicy
Verification Steps
petstore
petstore
. In the Client Protocol field, selectopenid-connect
.bob
, set the Email Verified switch to ON, and click Save.p
. Enter the password in both the fields, set the Temporary switch to OFF to avoid the password reset at the next login, and clickSet Password
.Now, let's run local cluster to test the kuadrantctl new command to generate authpolicy.
Clone the repo and checkout to the current PR branch
authpolicy
Setup cluster, istio and Gateway API CRDs
Build and install CLI in
bin/kuadrantctl
pathInstall Kuadrant service protection. The CLI can be used to install kuadrant v0.4.1
Deploy petstore backend API
Let's create Petstore's OpenAPI spec
GET /api/v1/cat
GET /api/v1/dog
Create the HTTPRoute using the CLI
Create Kuadrant's Auth Policy
Now, we are ready to test OpenAPI endpoints :exclamation:
GET /api/v1/cat
-> It's a public endpoint, hence should return 200 OkGET /api/v1/dog
-> It's a secured endpoint, hence, without credentials, it should return 401bob
user withp
password. We previously createdbob
user in Keycloak in thepetstore
realm.With the access token in place, let's try to get those puppies
should return 200 Ok