summaryrefslogtreecommitdiff
path: root/app/api/auth/saml/authn-request/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/auth/saml/authn-request/route.ts')
-rw-r--r--app/api/auth/saml/authn-request/route.ts54
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 })
+ }
+}