1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 })
}
}
|