@@ -19,34 +19,106 @@ your client ID or the intended audience for the token), the
1919` authorizationServer ` of your identity provider, and optionally a list of
2020` scopesRequired ` that must be present in the token's claims.
2121
22- ## Behavior
22+ ## Usage Modes
2323
24- ### Token Validation
24+ The Generic Auth Service supports two distinct modes of operation:
2525
26- When a request is received, the service will:
26+ ### 1. Toolbox Auth
2727
28- 1 . Extract the token from the ` <name>_token ` header (e.g.,
29- ` my-generic-auth_token ` ).
30- 2 . Fetch the JWKS from the configured ` authorizationServer ` (caching it in the
31- background) to verify the token's signature.
32- 3 . Validate that the token is not expired and its signature is valid.
33- 4 . Verify that the ` aud ` (audience) claim matches the configured ` audience ` .
34- claim contains all required scopes.
35- 5 . Return the validated claims to be used for [ Authenticated
36- Parameters] [ auth-params ] or [ Authorized Invocations] [ auth-invoke ] .
28+ This mode is used for Toolbox's native authentication/authorization features. It
29+ is active when you reference the auth service in a tool's configuration and
30+ ` mcpEnabled ` is set to false.
3731
38- [ auth-invoke ] : ../tools/_index.md#authorized-invocations
39- [ auth-params ] : ../tools/_index.md#authenticated-parameters
32+ - ** Header** : Expects the token in a custom header matching ` <name>_token `
33+ (e.g., ` my-generic-auth_token ` ).
34+ - ** Token Type** : Only supports ** JWT** (OIDC) tokens.
35+ - ** Usage** : Used for [ Authenticated Parameters] [ auth-params ] and [ Authorized
36+ Invocations] [ auth-invoke ] .
37+
38+ #### Token Validation
39+
40+ When a request is received in this mode, the service will:
4041
41- ## Example
42+ 1 . Extract the token from the ` <name>_token ` header.
43+ 2 . Treat it as a JWT (opaque tokens are not supported in this mode).
44+ 3 . Validates signature using JWKS fetched from ` authorizationServer ` .
45+ 4 . Verifies expiration (` exp ` ) and audience (` aud ` ).
46+ 5 . Verifies required scopes in ` scope ` claim.
47+
48+ #### Example
4249
4350``` yaml
4451kind : authServices
4552name : my-generic-auth
4653type : generic
4754audience : ${YOUR_OIDC_AUDIENCE}
4855authorizationServer : https://your-idp.example.com
49- mcpEnabled : false
56+ # mcpEnabled: false
57+ scopesRequired :
58+ - read
59+ - write
60+ ` ` `
61+
62+ #### Tool Usage Example
63+
64+ To use this auth service for **Authenticated Parameters** or **Authorized
65+ Invocations**, reference it in your tool configuration:
66+
67+ ` ` ` yaml
68+ kind : tool
69+ name : secure_query
70+ type : postgres-sql
71+ source : my-pg-instance
72+ statement : |
73+ SELECT * FROM data WHERE user_id = $1
74+ parameters :
75+ - name : user_id
76+ type : strings
77+ description : Auto-populated from token
78+ authServices :
79+ - name : my-generic-auth
80+ field : sub # Extract 'sub' claim from JWT
81+ authRequired :
82+ - my-generic-auth # Require valid token for invocation
83+ ` ` `
84+
85+ ### 2. MCP Authorization
86+
87+ This mode enforces global authentication for all MCP endpoints. It is active
88+ when ` mcpEnabled` is set to `true` in the auth service configuration.
89+
90+ - **Header**: Expects the token in the standard `Authorization: Bearer <token>`
91+ header.
92+ - **Token Type**: Supports both **JWT** and **Opaque** tokens.
93+ - **Usage**: Used to secure the entire MCP server.
94+
95+ # ### Token Validation
96+
97+ When a request is received in this mode, the service will :
98+
99+ 1. Extract the token from the `Authorization` header after `Bearer ` prefix.
100+ 2. Determine if the token is a JWT or an opaque token based on format (JWTs
101+ contain exactly two dots).
102+ 3. For **JWTs** :
103+ - Validates signature using JWKS fetched from `authorizationServer`.
104+ - Verifies expiration (`exp`) and audience (`aud`).
105+ - Verifies required scopes in `scope` claim.
106+ 4. For **Opaque Tokens** :
107+ - Calls the introspection endpoint (as listed in the `authorizationServer`'s
108+ OIDC configuration).
109+ - Verifies that the token is `active`.
110+ - Verifies expiration (`exp`) and audience (`aud`).
111+ - Verifies required scopes in `scope` field.
112+
113+ # ### Example
114+
115+ ` ` ` yaml
116+ kind: authServices
117+ name: my-generic-auth
118+ type: generic
119+ audience: ${YOUR_TOKEN_AUDIENCE}
120+ authorizationServer: https://your-idp.example.com
121+ mcpEnabled: true
50122scopesRequired:
51123 - read
52124 - write
@@ -56,6 +128,11 @@ scopesRequired:
56128${ENV_NAME} instead of hardcoding your secrets into the configuration file.
57129{{< /notice >}}
58130
131+ [auth-invoke] : ../tools/_index.md#authorized-invocations
132+ [auth-params] : ../tools/_index.md#authenticated-parameters
133+ [mcp-auth] :
134+ https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization
135+
59136# # Reference
60137
61138| **field** | **type** | **required** | **description** |
0 commit comments