- google-auth-library로 Google ID Token 검증 (backend) - @react-oauth/google GoogleLogin 컴포넌트 (frontend) - gcsc.co.kr 도메인 자동 승인(ACTIVE), 기타 도메인 PENDING - 기존 ID/PW 사용자와 OAuth 사용자 동일 계정 체계 통합 - AdminView: 사용자 인증방식(Google/ID PW) 뱃지 표시 - AdminView: OAuth 자동 승인 도메인 설정 UI - deploy.yml: VITE_GOOGLE_CLIENT_ID 빌드 환경변수 추가 - nginx: Cross-Origin-Opener-Policy 헤더 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { Router } from 'express'
|
|
import { requireAuth, requireRole } from '../auth/authMiddleware.js'
|
|
import {
|
|
getRegistrationSettings,
|
|
updateRegistrationSettings,
|
|
getOAuthSettings,
|
|
updateOAuthSettings,
|
|
getAllSettings,
|
|
} from './settingsService.js'
|
|
|
|
const router = Router()
|
|
|
|
router.use(requireAuth)
|
|
router.use(requireRole('ADMIN'))
|
|
|
|
// GET /api/settings — 전체 설정 조회
|
|
router.get('/', async (_req, res) => {
|
|
try {
|
|
const settings = await getAllSettings()
|
|
res.json(settings)
|
|
} catch (err) {
|
|
console.error('[settings] 조회 오류:', err)
|
|
res.status(500).json({ error: '설정 조회 중 오류가 발생했습니다.' })
|
|
}
|
|
})
|
|
|
|
// GET /api/settings/registration — 가입 설정 조회
|
|
router.get('/registration', async (_req, res) => {
|
|
try {
|
|
const settings = await getRegistrationSettings()
|
|
res.json(settings)
|
|
} catch (err) {
|
|
console.error('[settings] 가입 설정 조회 오류:', err)
|
|
res.status(500).json({ error: '가입 설정 조회 중 오류가 발생했습니다.' })
|
|
}
|
|
})
|
|
|
|
// PUT /api/settings/registration — 가입 설정 수정
|
|
router.put('/registration', async (req, res) => {
|
|
try {
|
|
const { autoApprove, defaultRole } = req.body
|
|
await updateRegistrationSettings({ autoApprove, defaultRole })
|
|
const updated = await getRegistrationSettings()
|
|
res.json(updated)
|
|
} catch (err) {
|
|
console.error('[settings] 가입 설정 수정 오류:', err)
|
|
res.status(500).json({ error: '가입 설정 수정 중 오류가 발생했습니다.' })
|
|
}
|
|
})
|
|
|
|
// GET /api/settings/oauth — OAuth 설정 조회
|
|
router.get('/oauth', async (_req, res) => {
|
|
try {
|
|
const settings = await getOAuthSettings()
|
|
res.json(settings)
|
|
} catch (err) {
|
|
console.error('[settings] OAuth 설정 조회 오류:', err)
|
|
res.status(500).json({ error: 'OAuth 설정 조회 중 오류가 발생했습니다.' })
|
|
}
|
|
})
|
|
|
|
// PUT /api/settings/oauth — OAuth 설정 수정
|
|
router.put('/oauth', async (req, res) => {
|
|
try {
|
|
const { autoApproveDomains } = req.body
|
|
await updateOAuthSettings({ autoApproveDomains })
|
|
const updated = await getOAuthSettings()
|
|
res.json(updated)
|
|
} catch (err) {
|
|
console.error('[settings] OAuth 설정 수정 오류:', err)
|
|
res.status(500).json({ error: 'OAuth 설정 수정 중 오류가 발생했습니다.' })
|
|
}
|
|
})
|
|
|
|
export default router
|