Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class AdminProperties(
val environment: String = "",
val grantSigningKey: String = "",
val grantHosts: Map<String, String> = emptyMap(),
val allowlistTtl: Duration = Duration.ofHours(24),
val allowlistTtl: Duration = Duration.ofHours(1),
val grantTokenTtl: Duration = Duration.ofMinutes(3),
val localBypass: Boolean = false,
val scheduleGraceWindow: Duration = Duration.ofHours(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ class AdminSecurityConfig {
// 결정적으로 이 체인에 묶인다(String 다중 패턴 조합에서 GET /admin-access/grant 가 메인 체인으로 새 401 나던 문제 차단).
.securityMatcher(adminPathMatcher())
.authorizeHttpRequests { it.anyRequest().permitAll() }
.csrf { it.ignoringRequestMatchers(ADMIN_PATHS.matcher("/admin-access/**")) }
.csrf {
// /admin-access/** 는 슬랙·디스코드 진입(서명검증으로 보호), /admin/session/** 는 폼이 아니라
// fetch(JSON) API(세션 남은시간·연장)라 CSRF 토큰을 실을 수 없다 — 둘 다 CSRF 제외한다.
// 나머지 /admin/** 폼(Thymeleaf)은 CSRF 를 유지한다(_csrf 히든).
it.ignoringRequestMatchers(
ADMIN_PATHS.matcher("/admin-access/**"),
ADMIN_PATHS.matcher("/admin/session/**"),
)
}
.sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) }
.build()

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ admin:
staging: https://staging.api.piki.day
prod: https://api.piki.day
# 허용 IP sliding TTL(무활동 만료, IP 변동 흡수). grant-token 은 원타임 링크 수명.
allowlist-ttl: ${ADMIN_ALLOWLIST_TTL:24h}
allowlist-ttl: ${ADMIN_ALLOWLIST_TTL:1h}
grant-token-ttl: 3m
# 로컬에서만 /admin 게이트(AdminAccessFilter) 우회. 배포 환경은 항상 false.
local-bypass: ${ADMIN_LOCAL_BYPASS:false}
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/templates/admin/fragments.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@
}
btn.addEventListener('click', function () {
btn.disabled = true;
fetch('/admin/session/extend', { method: 'POST' }).then(function (r) { return r.json(); })
// 실패(비 2xx·네트워크)면 기존 카운트다운을 유지한다 — 응답 실패를 "만료됨"으로 오표시하지 않는다.
fetch('/admin/session/extend', { method: 'POST' })
.then(function (r) { return r.ok ? r.json() : Promise.reject(); })
.then(function (d) { start(d.remainingSeconds); })
.catch(function () {})
.finally(function () { btn.disabled = false; });
});
load();
Expand Down
Loading