fix: support Kiro IDC (organization) token import

When logged in to Kiro IDE as an organization (AWS IAM Identity Center),
token import fails because IDC tokens require clientId/clientSecret for
refresh and use a different profileArn than social/builder-id accounts.

Changes:
- auto-import: read clientId/clientSecret from SSO cache client registration
  file, read profileArn from Kiro IDE profile.json, normalize ARN region
- import: accept IDC credentials, use KiroService.refreshToken with them,
  persist credentials for future automatic refreshes
- KiroAuthModal: pass IDC credentials from auto-detect through to import

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
quanturbo
2026-06-26 10:31:30 +07:00
committed by decolua
parent ce844899ed
commit 4d9da5db26
3 changed files with 91 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ export default function KiroAuthModal({ isOpen, onMethodSelect, onClose }) {
const [importing, setImporting] = useState(false);
const [autoDetecting, setAutoDetecting] = useState(false);
const [autoDetected, setAutoDetected] = useState(false);
const [idcCredentials, setIdcCredentials] = useState(null);
// Auto-detect token when import method is selected
useEffect(() => {
@@ -28,6 +29,7 @@ export default function KiroAuthModal({ isOpen, onMethodSelect, onClose }) {
setAutoDetecting(true);
setError(null);
setAutoDetected(false);
setIdcCredentials(null);
try {
const res = await fetch("/api/oauth/kiro/auto-import");
@@ -36,6 +38,16 @@ export default function KiroAuthModal({ isOpen, onMethodSelect, onClose }) {
if (data.found) {
setRefreshToken(data.refreshToken);
setAutoDetected(true);
// Store IDC/organization credentials if present
if (data.clientId && data.clientSecret) {
setIdcCredentials({
clientId: data.clientId,
clientSecret: data.clientSecret,
region: data.region,
authMethod: data.authMethod,
profileArn: data.profileArn,
});
}
} else {
setError(data.error || "Could not auto-detect token");
}
@@ -72,7 +84,10 @@ export default function KiroAuthModal({ isOpen, onMethodSelect, onClose }) {
const res = await fetch("/api/oauth/kiro/import", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refreshToken: refreshToken.trim() }),
body: JSON.stringify({
refreshToken: refreshToken.trim(),
...(idcCredentials || {}),
}),
});
const data = await res.json();