-
Notifications
You must be signed in to change notification settings - Fork 361
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
API for authorization #3138
Closed
Closed
API for authorization #3138
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package v1alpha1 | ||
|
||
// AuthorizationAction defines the action to take if a request matches the rule. | ||
type AuthorizationAction string | ||
|
||
const ( | ||
// AuthorizationActionAllow allows the request. | ||
AuthorizationActionAllow AuthorizationAction = "ALLOW" | ||
// AuthorizationActionDeny denies the request. | ||
AuthorizationActionDeny AuthorizationAction = "DENY" | ||
) | ||
|
||
// Authorization defines the configuration for request authorization. | ||
type Authorization struct { | ||
// Rules define a list of authorization rules. | ||
// +kubebuilder:validation:MinItems=1 | ||
Rules []AuthorizationRule `json:"policies"` | ||
} | ||
|
||
// AuthorizationRule defines the configuration for an authorization rule. | ||
type AuthorizationRule struct { | ||
// Action defines the action to take if a request matches the rule. | ||
// ALLOW allows the request, and DENY denies the request. | ||
// +kubebuilder:validation:Enum=ALLOW;DENY | ||
Action AuthorizationAction `json:"action"` | ||
|
||
// Policies define which principals are allowed/denied access to specified permissions based on the action. | ||
Policies []AuthorizationPolicy `json:"policy"` | ||
} | ||
|
||
// AuthorizationPolicy defines the configuration for an authorization policy. | ||
type AuthorizationPolicy struct { | ||
// Principals define the list of principals that are allowed/denied access based on the action. | ||
// If no principals are specified, all requests are matched. | ||
Principles []Principle `json:"principles"` | ||
|
||
// Permissions define the list of permissions that are allowed/denied access based on the action. | ||
// If no permissions are specified, all requests are matched. | ||
Permissions []Permission `json:"permissions"` | ||
} | ||
|
||
// Principle defines the configuration for a principle. | ||
type Principle struct { | ||
// SourceIP is an IP CIDR that represents the range of the source IP addresses for clients. | ||
// This address will honor proxy protocol, but will not honor XFF. | ||
// For example, `192.168.0.1/32`, `192.168.0.0/24`, `001:db8::/64`. | ||
// One of SourceIP or JWTClaim must be specified. | ||
SourceIP *string `json:"sourceIP,omitempty"` | ||
|
||
// JWTClaims is a JWT claim that can be used to authorize requests. | ||
// To use this claim, the JWT settings must be configured in the SecurityPolicy, | ||
// and the specified claim must be present in the JWT token. | ||
// One of SourceIP or JWTClaim must be specified. | ||
JWTClaim *JWTClaim | ||
} | ||
|
||
// JWTClaim defines a JWT claim that can be used to authorize requests. | ||
type JWTClaim struct { | ||
// Name is the name of the claim. | ||
Name string `json:"name"` | ||
|
||
// Value is the value of the claim. | ||
Value string `json:"value"` | ||
} | ||
|
||
// Permission defines actions that the authorized principals can take. | ||
type Permission struct { | ||
// Methods define the list of HTTP methods that are allowed/denied access based on the action. | ||
// If no methods are specified, all methods are matched. | ||
Method []string `json:"method"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thinking like groups parameter. Use case could be "i want allow group x only" or "i want allow/deny groups x y z".