mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-04-21 07:02:05 +00:00
feat(kiro): add AWS Builder ID authentication support
- Add --kiro-aws-login flag for AWS Builder ID device code flow - Add DoKiroAWSLogin function for AWS SSO OIDC authentication - Complete Kiro integration with AWS, Google OAuth, and social auth - Add kiro executor, translator, and SDK components - Update browser support for Kiro authentication flows
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
||||
@@ -50,7 +51,25 @@ type BaseAPIHandler struct {
|
||||
Cfg *config.SDKConfig
|
||||
|
||||
// OpenAICompatProviders is a list of provider names for OpenAI compatibility.
|
||||
OpenAICompatProviders []string
|
||||
openAICompatProviders []string
|
||||
openAICompatMutex sync.RWMutex
|
||||
}
|
||||
|
||||
// GetOpenAICompatProviders safely returns a copy of the provider names
|
||||
func (h *BaseAPIHandler) GetOpenAICompatProviders() []string {
|
||||
h.openAICompatMutex.RLock()
|
||||
defer h.openAICompatMutex.RUnlock()
|
||||
result := make([]string, len(h.openAICompatProviders))
|
||||
copy(result, h.openAICompatProviders)
|
||||
return result
|
||||
}
|
||||
|
||||
// SetOpenAICompatProviders safely sets the provider names
|
||||
func (h *BaseAPIHandler) SetOpenAICompatProviders(providers []string) {
|
||||
h.openAICompatMutex.Lock()
|
||||
defer h.openAICompatMutex.Unlock()
|
||||
h.openAICompatProviders = make([]string, len(providers))
|
||||
copy(h.openAICompatProviders, providers)
|
||||
}
|
||||
|
||||
// NewBaseAPIHandlers creates a new API handlers instance.
|
||||
@@ -63,11 +82,12 @@ type BaseAPIHandler struct {
|
||||
// Returns:
|
||||
// - *BaseAPIHandler: A new API handlers instance
|
||||
func NewBaseAPIHandlers(cfg *config.SDKConfig, authManager *coreauth.Manager, openAICompatProviders []string) *BaseAPIHandler {
|
||||
return &BaseAPIHandler{
|
||||
Cfg: cfg,
|
||||
AuthManager: authManager,
|
||||
OpenAICompatProviders: openAICompatProviders,
|
||||
h := &BaseAPIHandler{
|
||||
Cfg: cfg,
|
||||
AuthManager: authManager,
|
||||
}
|
||||
h.SetOpenAICompatProviders(openAICompatProviders)
|
||||
return h
|
||||
}
|
||||
|
||||
// UpdateClients updates the handlers' client list and configuration.
|
||||
@@ -363,7 +383,7 @@ func (h *BaseAPIHandler) parseDynamicModel(modelName string) (providerName, mode
|
||||
}
|
||||
|
||||
// Check if the provider is a configured openai-compatibility provider
|
||||
for _, pName := range h.OpenAICompatProviders {
|
||||
for _, pName := range h.GetOpenAICompatProviders() {
|
||||
if pName == providerPart {
|
||||
return providerPart, modelPart, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user