Skip to content

Commit 517a3a5

Browse files
authored
feat: add middleware comp proper registrations (#3956)
Signed-off-by: Samantha Coyle <[email protected]>
1 parent 038ebb1 commit 517a3a5

File tree

8 files changed

+347
-0
lines changed

8 files changed

+347
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: bearer
5+
version: v1
6+
status: stable
7+
title: "Bearer Token Authentication"
8+
description: |
9+
The Bearer middleware provides JWT token authentication for HTTP requests.
10+
It validates Bearer tokens in the Authorization header and can extract claims for downstream processing.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-bearer/
14+
metadata:
15+
- name: jwksURL
16+
type: string
17+
required: true
18+
description: "The URL of the JSON Web Key Set (JWKS) endpoint"
19+
example: "https://accounts.google.com/.well-known/jwks.json"
20+
- name: issuer
21+
type: string
22+
required: true
23+
description: "The expected issuer of the JWT tokens"
24+
example: "https://accounts.google.com"
25+
- name: audience
26+
type: string
27+
required: true
28+
description: "The expected audience of the JWT tokens"
29+
example: "my-app"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: oauth2
5+
version: v1
6+
status: alpha
7+
title: "OAuth2 Authentication"
8+
description: |
9+
The OAuth2 middleware provides OAuth2 authentication for HTTP requests.
10+
It handles OAuth2 flows and token validation for securing API endpoints.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-oauth2/
14+
authenticationProfiles:
15+
- title: "OAuth2 Authentication"
16+
description: "Configure OAuth2 authentication with any OAuth2 provider"
17+
metadata:
18+
- name: clientID
19+
type: string
20+
required: true
21+
description: "The OAuth2 client ID from your OAuth2 provider"
22+
example: "client-id"
23+
- name: clientSecret
24+
type: string
25+
required: true
26+
description: "The OAuth2 client secret from your OAuth2 provider"
27+
sensitive: true
28+
example: "client-secret"
29+
- name: authURL
30+
type: string
31+
required: true
32+
description: "The OAuth2 authorization URL from your provider"
33+
example: "https://accounts.google.com/o/oauth2/v2/auth"
34+
- name: tokenURL
35+
type: string
36+
required: true
37+
description: "The OAuth2 token URL from your provider"
38+
example: "https://oauth2.googleapis.com/token"
39+
- name: scopes
40+
type: string
41+
required: false
42+
description: "OAuth2 scopes to request from your provider"
43+
example: "openid profile email"
44+
metadata:
45+
- name: redirectURL
46+
type: string
47+
required: false
48+
description: "The OAuth2 redirect URL for your application"
49+
example: "http://localhost:8080/callback"
50+
- name: authHeaderName
51+
type: string
52+
required: false
53+
description: "The name of the authorization header to use"
54+
example: "Authorization"
55+
default: "Authorization"
56+
- name: forceHTTPS
57+
type: string
58+
required: false
59+
description: "Whether to force HTTPS for the redirect URL"
60+
example: "true"
61+
default: "false"
62+
- name: pathFilter
63+
type: string
64+
required: false
65+
description: "Regular expression to filter which paths require authentication"
66+
example: "^/api/.*"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: oauth2clientcredentials
5+
version: v1
6+
status: alpha
7+
title: "OAuth2 Client Credentials"
8+
description: |
9+
The OAuth2 Client Credentials middleware provides OAuth2 client credentials flow authentication.
10+
It handles machine-to-machine authentication using client credentials.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/oauth2clientcredentials/
14+
authenticationProfiles:
15+
- title: "OAuth2 Client Credentials"
16+
description: "Configure OAuth2 client credentials authentication with any OAuth2 provider"
17+
metadata:
18+
- name: clientID
19+
type: string
20+
required: true
21+
description: "The client ID of your application that is created as part of a credential hosted by a OAuth-enabled platform"
22+
example: "client-id"
23+
- name: clientSecret
24+
type: string
25+
required: true
26+
description: "The client secret of your application that is created as part of a credential hosted by a OAuth-enabled platform"
27+
sensitive: true
28+
example: "client-secret"
29+
- name: scopes
30+
type: string
31+
required: false
32+
description: "A list of space-delimited, case-sensitive strings of scopes which are typically used for authorization in the application"
33+
example: "https://www.googleapis.com/auth/userinfo.email"
34+
- name: tokenURL
35+
type: string
36+
required: true
37+
description: "The endpoint is used by the client to obtain an access token by presenting its authorization grant or refresh token"
38+
example: "https://accounts.google.com/o/oauth2/token"
39+
metadata:
40+
- name: pathFilter
41+
type: string
42+
required: false
43+
description: "Regular expression to filter which paths require authentication"
44+
example: "^/api/.*"
45+
- name: headerName
46+
type: string
47+
required: true
48+
description: "The authorization header name to forward to your application"
49+
example: "authorization"
50+
- name: endpointParamsQuery
51+
type: string
52+
required: false
53+
description: "Specifies additional parameters for requests to the token endpoint"
54+
example: "param1=value1&param2=value2"
55+
- name: authStyle
56+
type: integer
57+
required: false
58+
description: "Optionally specifies how the endpoint wants the client ID & client secret sent. 0: Auto-detect (tries both ways and caches the successful way), 1: Sends client_id and client_secret in POST body as application/x-www-form-urlencoded parameters, 2: Sends client_id and client_secret using HTTP Basic Authorization"
59+
example: 0
60+
default: 0
61+
allowedValues:
62+
- 0
63+
- 1
64+
- 2

middleware/http/opa/metadata.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: opa
5+
version: v1
6+
status: alpha
7+
title: "Open Policy Agent (OPA)"
8+
description: |
9+
The OPA middleware allows you to enforce policies on HTTP requests using Open Policy Agent (OPA) Rego policies.
10+
It evaluates incoming requests against your Rego policies and can allow, deny, or modify requests based on the policy results.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-opa/
14+
metadata:
15+
- name: rego
16+
type: string
17+
required: true
18+
description: "The Rego policy code that will be evaluated for each request. The policy package must be http and the policy must set data.http.allow"
19+
- name: defaultStatus
20+
type: number
21+
required: false
22+
description: "The status code to return for denied responses"
23+
example: 403
24+
default: 403
25+
- name: includedHeaders
26+
type: string
27+
required: false
28+
description: "Comma-separated set of case-insensitive headers to include in the request input. Request headers are not passed to the policy by default. Include to receive incoming request headers in the input"
29+
example: "x-my-custom-header, x-jwt-header"
30+
- name: readBody
31+
type: string
32+
required: false
33+
description: "Controls whether the middleware reads the entire request body in-memory and make it available for policy decisions"
34+
example: false
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: ratelimit
5+
version: v1
6+
status: stable
7+
title: "Rate Limiting"
8+
description: |
9+
The Rate Limiting middleware provides request rate limiting functionality.
10+
It can limit requests based on various criteria like IP address, user, or custom keys.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-rate-limit/
14+
metadata:
15+
- name: maxRequestsPerSecond
16+
type: integer
17+
required: true
18+
description: "Maximum number of requests allowed per second"
19+
example: 100
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: routerchecker
5+
version: v1
6+
status: alpha
7+
title: "Router Checker"
8+
description: |
9+
The RouterChecker HTTP middleware component leverages regexp to check the validity of HTTP request routing to prevent invalid routers from entering the Dapr cluster. In turn, the RouterChecker component filters out bad requests and reduces noise in the telemetry and log data.
10+
urls:
11+
- title: Reference
12+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-routerchecker/
13+
metadata:
14+
- name: rule
15+
type: string
16+
required: true
17+
description: "Regular expression to filter which paths are allowed"
18+
example: "^[A-Za-z0-9/._-]+$"
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: sentinel
5+
version: v1
6+
status: alpha
7+
title: "Sentinel"
8+
description: |
9+
Use Sentinel middleware to guarantee the reliability and resiliency of your application.
10+
Sentinel is a powerful fault-tolerance component that takes "flow" as the breakthrough point and covers multiple fields including flow control, traffic shaping, concurrency limiting, circuit breaking, and adaptive system protection to guarantee the reliability and resiliency of microservices.
11+
12+
The Sentinel HTTP middleware enables Dapr to facilitate Sentinel's powerful abilities to protect your application. You can refer to Sentinel Wiki for more details on Sentinel.
13+
urls:
14+
- title: Reference
15+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-sentinel/
16+
metadata:
17+
- name: appName
18+
type: string
19+
required: true
20+
description: "The application name for Sentinel"
21+
example: "nodeapp"
22+
- name: logDir
23+
type: string
24+
required: false
25+
description: "Directory for Sentinel log files"
26+
example: "/var/tmp"
27+
- name: flowRules
28+
type: string
29+
required: false
30+
description: "JSON array of flow control rules to limit request rate"
31+
example: |
32+
[
33+
{
34+
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
35+
"threshold": 10,
36+
"tokenCalculateStrategy": 0,
37+
"controlBehavior": 0
38+
}
39+
]
40+
- name: circuitBreakerRules
41+
type: string
42+
required: false
43+
description: "JSON array of circuit breaker rules to handle failures"
44+
example: |
45+
[
46+
{
47+
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
48+
"minRequestAmount": 5,
49+
"statIntervalMs": 1000,
50+
"maxAllowedRtMs": 50,
51+
"maxSlowRequestRatio": 0.5
52+
}
53+
]
54+
- name: hotSpotParamRules
55+
type: string
56+
required: false
57+
description: "JSON array of hotspot parameter rules for parameter-based flow control"
58+
example: |
59+
[
60+
{
61+
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
62+
"paramIdx": 0,
63+
"threshold": 10,
64+
"maxQueueingTimeMs": 500
65+
}
66+
]
67+
- name: isolationRules
68+
type: string
69+
required: false
70+
description: "JSON array of isolation rules for thread pool isolation"
71+
example: |
72+
[
73+
{
74+
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
75+
"maxConcurrency": 10,
76+
"maxQueueingTimeMs": 500
77+
}
78+
]
79+
- name: systemRules
80+
type: string
81+
required: false
82+
description: "JSON array of system protection rules for overall system protection"
83+
example: |
84+
[
85+
{
86+
"avgRt": 50,
87+
"maxThread": 10,
88+
"qps": 20
89+
}
90+
]

middleware/http/wasm/metadata.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=../../../component-metadata-schema.json
2+
schemaVersion: v1
3+
type: middleware
4+
name: wasm
5+
version: v1
6+
status: alpha
7+
title: "WebAssembly (WASM)"
8+
description: |
9+
The WebAssembly middleware allows you to run custom logic written in WASM.
10+
It can execute WASM modules to process HTTP requests and responses.
11+
urls:
12+
- title: Reference
13+
url: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-wasm/
14+
metadata:
15+
- name: url
16+
type: string
17+
required: true
18+
description: "URL of the WASM module"
19+
example: "https://example.com/middleware.wasm"
20+
- name: guestConfig
21+
required: false
22+
description: "Configuration object passed to the WASM module"
23+
example: |
24+
{
25+
"timeout": "5s",
26+
"maxMemory": "10MB"
27+
}

0 commit comments

Comments
 (0)