기능구현중
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
/**
|
||||
* Google OAuth 시작
|
||||
* GET /api/auth/google
|
||||
*
|
||||
* Query params:
|
||||
* - extend: 'groups' - 구글 그룹 접근 권한 추가 요청
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig()
|
||||
const query = getQuery(event)
|
||||
|
||||
const clientId = config.googleClientId || process.env.GOOGLE_CLIENT_ID
|
||||
const redirectUri = config.googleRedirectUri || process.env.GOOGLE_REDIRECT_URI || 'http://localhost:3000/api/auth/google/callback'
|
||||
@@ -12,7 +16,18 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 500, message: 'Google OAuth가 설정되지 않았습니다.' })
|
||||
}
|
||||
|
||||
const scope = encodeURIComponent('openid email profile')
|
||||
// 기본 scope + 확장 scope
|
||||
let scopes = ['openid', 'email', 'profile']
|
||||
|
||||
// 구글 그룹 권한 요청 시 추가 scope
|
||||
if (query.extend === 'groups') {
|
||||
scopes.push(
|
||||
'https://www.googleapis.com/auth/gmail.readonly', // 그룹 메일 읽기
|
||||
'https://www.googleapis.com/auth/cloud-identity.groups.readonly' // 그룹 정보 읽기
|
||||
)
|
||||
}
|
||||
|
||||
const scope = encodeURIComponent(scopes.join(' '))
|
||||
const state = Math.random().toString(36).substring(7) // CSRF 방지
|
||||
|
||||
// state를 쿠키에 저장
|
||||
|
||||
Reference in New Issue
Block a user