mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-09 04:48:13 +02:00
mcp: split mcp into server and client for better option grouping (#5666)
This commit is contained in:
parent
d36c48a2bc
commit
db6449ecca
11 changed files with 1156 additions and 934 deletions
|
@ -138,21 +138,21 @@ func BuildHostInfo(cfg *config.Config, prefix string) (map[string]ServerHostInfo
|
|||
Host: host,
|
||||
URL: policy.GetFrom(),
|
||||
}
|
||||
if policy.MCP.UpstreamOAuth2 != nil {
|
||||
if oa := policy.MCP.GetServerUpstreamOAuth2(); oa != nil {
|
||||
v.Config = &oauth2.Config{
|
||||
ClientID: policy.MCP.UpstreamOAuth2.ClientID,
|
||||
ClientSecret: policy.MCP.UpstreamOAuth2.ClientSecret,
|
||||
ClientID: oa.ClientID,
|
||||
ClientSecret: oa.ClientSecret,
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: policy.MCP.UpstreamOAuth2.Endpoint.AuthURL,
|
||||
TokenURL: policy.MCP.UpstreamOAuth2.Endpoint.TokenURL,
|
||||
AuthStyle: authStyleEnum(policy.MCP.UpstreamOAuth2.Endpoint.AuthStyle),
|
||||
AuthURL: oa.Endpoint.AuthURL,
|
||||
TokenURL: oa.Endpoint.TokenURL,
|
||||
AuthStyle: authStyleEnum(oa.Endpoint.AuthStyle),
|
||||
},
|
||||
RedirectURL: (&url.URL{
|
||||
Scheme: "https",
|
||||
Host: host,
|
||||
Path: path.Join(prefix, oauthCallbackEndpoint),
|
||||
}).String(),
|
||||
Scopes: policy.MCP.UpstreamOAuth2.Scopes,
|
||||
Scopes: oa.Scopes,
|
||||
}
|
||||
}
|
||||
servers[host] = v
|
||||
|
|
|
@ -25,13 +25,13 @@ func TestBuildOAuthConfig(t *testing.T) {
|
|||
Description: "description-1",
|
||||
LogoURL: "https://logo.example.com",
|
||||
From: "https://mcp1.example.com",
|
||||
MCP: &config.MCP{},
|
||||
MCP: &config.MCP{Server: &config.MCPServer{}},
|
||||
},
|
||||
{
|
||||
Name: "mcp-2",
|
||||
From: "https://mcp2.example.com",
|
||||
MCP: &config.MCP{
|
||||
UpstreamOAuth2: &config.UpstreamOAuth2{
|
||||
Server: &config.MCPServer{UpstreamOAuth2: &config.UpstreamOAuth2{
|
||||
ClientID: "client_id",
|
||||
ClientSecret: "client_secret",
|
||||
Endpoint: config.OAuth2Endpoint{
|
||||
|
@ -39,22 +39,18 @@ func TestBuildOAuthConfig(t *testing.T) {
|
|||
TokenURL: "https://auth.example.com/token",
|
||||
AuthStyle: config.OAuth2EndpointAuthStyleInParams,
|
||||
},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "mcp-client-1",
|
||||
From: "https://client1.example.com",
|
||||
MCP: &config.MCP{
|
||||
PassUpstreamAccessToken: true,
|
||||
},
|
||||
MCP: &config.MCP{Client: &config.MCPClient{}},
|
||||
},
|
||||
{
|
||||
Name: "mcp-client-2",
|
||||
From: "https://client2.example.com",
|
||||
MCP: &config.MCP{
|
||||
PassUpstreamAccessToken: true,
|
||||
},
|
||||
MCP: &config.MCP{Client: &config.MCPClient{}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -105,14 +101,12 @@ func TestHostInfo_IsMCPClientForHost(t *testing.T) {
|
|||
{
|
||||
Name: "mcp-server",
|
||||
From: "https://server.example.com",
|
||||
MCP: &config.MCP{},
|
||||
MCP: &config.MCP{Server: &config.MCPServer{}},
|
||||
},
|
||||
{
|
||||
Name: "mcp-client",
|
||||
From: "https://client.example.com",
|
||||
MCP: &config.MCP{
|
||||
PassUpstreamAccessToken: true,
|
||||
},
|
||||
MCP: &config.MCP{Client: &config.MCPClient{}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue