diff options
| author | joonhoekim <26rote@gmail.com> | 2025-06-20 11:47:15 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-06-20 11:47:15 +0000 |
| commit | abd9f950bbd95b9ad713a26d3fd8a7e0282b7c51 (patch) | |
| tree | aafc71d5ff23962c2d6d5e902c66ee070b7ac068 /app/api/auth/saml | |
| parent | 994defd6446ce20c4b4e0d6cc91688b0e64230a4 (diff) | |
(김준회) SAML 2.0 SSO (Knox Portal) 추가
Diffstat (limited to 'app/api/auth/saml')
| -rw-r--r-- | app/api/auth/saml/authn-request/route.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/api/auth/saml/authn-request/route.ts b/app/api/auth/saml/authn-request/route.ts new file mode 100644 index 00000000..e3cb8a47 --- /dev/null +++ b/app/api/auth/saml/authn-request/route.ts @@ -0,0 +1,54 @@ +import { NextRequest, NextResponse } from 'next/server' +import { createAuthnRequest } from '../../[...nextauth]/saml/utils' + +const samlEnvironment = { + NODE_ENV: process.env.NODE_ENV, + SAML_USE_MOCKUP: process.env.SAML_USE_MOCKUP, + NEXTAUTH_URL: process.env.NEXTAUTH_URL, +} + +// 환경변수 체크 +function checkEnvironment() { + console.log('📊 Environment check:', JSON.stringify(samlEnvironment, null, 2)) + +} + +// 요청 받으면 따로 파싱할 것 없이 동일하게 행동하므로 아규먼트 없음 +export async function GET() { + console.log('🚀 SAML AuthnRequest API started') + checkEnvironment() + + try { + console.log('SSO STEP 1: Create AuthnRequest') + + const startTime = Date.now() + const loginUrl = await createAuthnRequest() + const endTime = Date.now() + + console.log('SAML AuthnRequest created successfully:', { + url: loginUrl, + urlLength: loginUrl.length, + processingTime: `${endTime - startTime}ms`, + timestamp: new Date().toISOString() + }) + + return NextResponse.json({ + loginUrl, + success: true, + mode: 'real', + message: 'Using real SAML IdP' + }) + } catch (error) { + console.error('Failed to create SAML AuthnRequest:', { + error: error instanceof Error ? error.message : 'Unknown error', + stack: error instanceof Error ? error.stack : undefined, + timestamp: new Date().toISOString() + }) + + return NextResponse.json({ + error: 'Failed to create SAML AuthnRequest', + details: error instanceof Error ? error.message : 'Unknown error', + success: false + }, { status: 500 }) + } +} |
