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

kap remove hosts from authscheme #99

Merged
merged 1 commit into from
Nov 11, 2022
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
39 changes: 34 additions & 5 deletions api/v1beta1/authpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,53 @@ package v1beta1
import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
authorinov1beta1 "github.com/kuadrant/authorino/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

type AuthSchemeSpec struct {
// Named sets of JSON patterns that can be referred in `when` conditionals and in JSON-pattern matching policy rules.
Patterns map[string]authorinov1beta1.JSONPatternExpressions `json:"patterns,omitempty"`

// Conditions for the AuthConfig to be enforced.
// If omitted, the AuthConfig will be enforced for all requests.
// If present, all conditions must match for the AuthConfig to be enforced; otherwise, Authorino skips the AuthConfig and returns immediately with status OK.
Conditions []authorinov1beta1.JSONPattern `json:"when,omitempty"`

// List of identity sources/authentication modes.
// At least one config of this list MUST evaluate to a valid identity for a request to be successful in the identity verification phase.
Identity []*authorinov1beta1.Identity `json:"identity,omitempty"`

// List of metadata source configs.
// Authorino fetches JSON content from sources on this list on every request.
Metadata []*authorinov1beta1.Metadata `json:"metadata,omitempty"`

// Authorization is the list of authorization policies.
// All policies in this list MUST evaluate to "true" for a request be successful in the authorization phase.
Authorization []*authorinov1beta1.Authorization `json:"authorization,omitempty"`

// List of response configs.
// Authorino gathers data from the auth pipeline to build custom responses for the client.
Response []*authorinov1beta1.Response `json:"response,omitempty"`

// Custom denial response codes, statuses and headers to override default 40x's.
DenyWith *authorinov1beta1.DenyWith `json:"denyWith,omitempty"`
}

type AuthPolicySpec struct {
// TargetRef identifies an API object to apply policy to.
TargetRef gatewayapiv1alpha2.PolicyTargetReference `json:"targetRef"`

// Rule describe the requests that will be routed to external authorization provider
AuthRules []*AuthRule `json:"rules,omitempty"`
AuthRules []AuthRule `json:"rules,omitempty"`

// AuthSchemes are embedded Authorino's AuthConfigs
AuthScheme *authorinov1beta1.AuthConfigSpec `json:"authScheme,omitempty"`
AuthScheme AuthSchemeSpec `json:"authScheme,omitempty"`
}

type AuthRule struct {
Expand Down
98 changes: 87 additions & 11 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions bundle/manifests/kuadrant.io_authpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,6 @@ spec:
type: object
type: object
type: object
hosts:
description: The list of public host names of the services protected
by this authentication/authorization scheme. Authorino uses
the requested host to lookup for the corresponding authentication/authorization
configs to enforce.
items:
type: string
type: array
identity:
description: List of identity sources/authentication modes. At
least one config of this list MUST evaluate to a valid identity
Expand Down Expand Up @@ -1672,8 +1664,6 @@ spec:
type: string
type: object
type: array
required:
- hosts
type: object
rules:
description: Rule describe the requests that will be routed to external
Expand Down
10 changes: 0 additions & 10 deletions config/crd/bases/kuadrant.io_authpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,6 @@ spec:
type: object
type: object
type: object
hosts:
description: The list of public host names of the services protected
by this authentication/authorization scheme. Authorino uses
the requested host to lookup for the corresponding authentication/authorization
configs to enforce.
items:
type: string
type: array
identity:
description: List of identity sources/authentication modes. At
least one config of this list MUST evaluate to a valid identity
Expand Down Expand Up @@ -1671,8 +1663,6 @@ spec:
type: string
type: object
type: array
required:
- hosts
type: object
rules:
description: Rule describe the requests that will be routed to external
Expand Down
6 changes: 3 additions & 3 deletions config/samples/kuadrant_v1beta1_authpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ spec:
methods: ["DELETE", "POST"]
paths: ["/admin*"]
authScheme:
hosts: ["api.toystore.com"]
identity:
- name: friends
apiKey:
labelSelectors:
group: friends
selector:
matchLabels:
group: friends
credentials:
in: authorization_header
keySelector: APIKEY
Loading