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

api: HTTP APIKey Auth Filter #36709

Merged
merged 15 commits into from
Nov 1, 2024
1 change: 1 addition & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ proto_library(
"//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg",
"//envoy/extensions/filters/http/admission_control/v3:pkg",
"//envoy/extensions/filters/http/alternate_protocols_cache/v3:pkg",
"//envoy/extensions/filters/http/api_key_auth/v3:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg",
"//envoy/extensions/filters/http/aws_request_signing/v3:pkg",
"//envoy/extensions/filters/http/bandwidth_limit/v3:pkg",
Expand Down
12 changes: 12 additions & 0 deletions api/envoy/extensions/filters/http/api_key_auth/v3/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py.

load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")

licenses(["notice"]) # Apache 2

api_proto_package(
deps = [
"//envoy/config/core/v3:pkg",
"@com_github_cncf_xds//udpa/annotations:pkg",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
syntax = "proto3";

package envoy.extensions.filters.http.api_key_auth.v3;

import "envoy/config/core/v3/base.proto";

import "udpa/annotations/sensitive.proto";
import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.filters.http.api_key_auth.v3";
option java_outer_classname = "ApiKeyAuthProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/api_key_auth/v3;api_key_authv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: APIKey Auth]
// APIKey Auth :ref:`configuration overview <config_http_filters_api_key_auth>`.
// [#extension: envoy.filters.http.api_key_auth]

// API Key HTTP authentication.
//
// Example:
//
// .. code-block:: yaml
//
// authentication_header: "X-API-KEY"
// keys:
// inline_string: |-
// apikey1:user1
sanposhiho marked this conversation as resolved.
Show resolved Hide resolved
// apikey2:user2
//
message APIKeyAuth {
sanposhiho marked this conversation as resolved.
Show resolved Hide resolved
// keys used to authenticate the user.
// It should be a map of apikey to user.
config.core.v3.DataSource keys = 1 [(udpa.annotations.sensitive) = true];

// The header name to forward an authenticated user.
//
// If it is not specified, the username will not be forwarded.
string forward_username_header = 2
Copy link
Member

@zhaohuabing zhaohuabing Oct 21, 2024

Choose a reason for hiding this comment

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

I suggest removing this at the first run. We can use a metadata to pass it(username or clientid) to later filters if it's required in the future.

[(validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}];

// The location of the API key.
oneof location {
sanposhiho marked this conversation as resolved.
Show resolved Hide resolved
// The header name to fetch the key.
string authentication_header = 3;
// The query parameter name to fetch the key.
string authentication_query = 4;
// The cookie name to fetch the key.
string authentication_cookie = 5;
}
}

// Extra settings that may be added to per-route configuration for
// a virtual host or a cluster.
message APIKeyAuthPerRoute {
// keys used to authenticate the user for this route.
sanposhiho marked this conversation as resolved.
Show resolved Hide resolved
config.core.v3.DataSource keys = 1
[(validate.rules).message = {required: true}, (udpa.annotations.sensitive) = true];
}
1 change: 1 addition & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ proto_library(
"//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg",
"//envoy/extensions/filters/http/admission_control/v3:pkg",
"//envoy/extensions/filters/http/alternate_protocols_cache/v3:pkg",
"//envoy/extensions/filters/http/api_key_auth/v3:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg",
"//envoy/extensions/filters/http/aws_request_signing/v3:pkg",
"//envoy/extensions/filters/http/bandwidth_limit/v3:pkg",
Expand Down