fix(security): improve access control and storage security (#518)

* fix(security): improve access control and storage security

* fix(security): set NODE_ENV in dockerfiles and sign local storage get urls with lru cache
This commit is contained in:
Yiling-J
2026-11-05 20:49:38 +08:00
committed by GitHub
parent 0dc0bbeb03
commit 65e2ac1383
26 changed files with 811 additions and 208 deletions
@@ -199,14 +199,12 @@ export function FileViewerRightSidebar({
attachmentIds,
annotations,
replyToId,
guestUserId,
second,
}: {
text: string
attachmentIds: string[]
annotations?: Annotation[]
replyToId?: string | null
guestUserId?: string
second?: number | null
}) => {
if (isPublic) {
@@ -225,7 +223,6 @@ export function FileViewerRightSidebar({
{
headers: {
'x-share-password': password,
...(guestUserId ? { 'x-guest-user-id': guestUserId } : {}),
},
},
)
@@ -310,7 +307,7 @@ export function FileViewerRightSidebar({
setIsGuestPopupOpen(true)
return
}
createComment({ text, attachmentIds, annotations, replyToId, guestUserId, second })
createComment({ text, attachmentIds, annotations, replyToId, second })
} else {
createComment({ text, attachmentIds, annotations, replyToId, second })
}
@@ -320,10 +317,9 @@ export function FileViewerRightSidebar({
setReplyingTo(null)
}
const handleGuestSuccess = (guestUserId: string) => {
console.log('[handleGuestSuccess] guestUserId:', guestUserId)
const handleGuestSuccess = () => {
if (pendingComment) {
createComment({ ...pendingComment, guestUserId })
createComment({ ...pendingComment })
setPendingComment(null)
setReplyingTo(null)
}
@@ -473,6 +469,7 @@ export function FileViewerRightSidebar({
isOpen={isGuestPopupOpen}
onClose={() => setIsGuestPopupOpen(false)}
onSuccess={handleGuestSuccess}
shareId={shareId || undefined}
>
<ChatInput
projectId={projectId}
@@ -170,14 +170,12 @@ export function MobileFileBottomSheet({
attachmentIds,
annotations,
replyToId,
guestUserId,
second,
}: {
text: string
attachmentIds: string[]
annotations?: Annotation[]
replyToId?: string | null
guestUserId?: string
second?: number | null
}) => {
if (isPublic) {
@@ -196,7 +194,6 @@ export function MobileFileBottomSheet({
{
headers: {
'x-share-password': password,
...(guestUserId ? { 'x-guest-user-id': guestUserId } : {}),
},
},
)
@@ -285,7 +282,6 @@ export function MobileFileBottomSheet({
attachmentIds,
annotations,
replyToId: actualReplyToId,
guestUserId,
second,
})
}
@@ -295,9 +291,9 @@ export function MobileFileBottomSheet({
setReplyingTo(null)
}
const handleGuestSuccess = (guestUserId: string) => {
const handleGuestSuccess = () => {
if (pendingComment) {
createComment({ ...pendingComment, guestUserId })
createComment({ ...pendingComment })
setPendingComment(null)
setReplyingTo(null)
}
@@ -442,6 +438,7 @@ export function MobileFileBottomSheet({
isOpen={isGuestPopupOpen}
onClose={() => setIsGuestPopupOpen(false)}
onSuccess={handleGuestSuccess}
shareId={shareId || undefined}
>
<ChatInput
projectId={projectId}
@@ -13,6 +13,7 @@ interface GuestIdentityPopupProps {
isOpen: boolean
onClose: () => void
onSuccess: (guestUserId: string) => void
shareId?: string
children?: React.ReactNode
}
@@ -20,6 +21,7 @@ export function GuestIdentityPopup({
isOpen,
onClose,
onSuccess,
shareId,
children,
}: GuestIdentityPopupProps) {
const [name, setName] = useState('')
@@ -34,7 +36,7 @@ export function GuestIdentityPopup({
try {
const res = await client.api.identify.$post({
json: { username: name, email: email },
json: { username: name, email: email, shareId: shareId || undefined },
})
if (!res.ok) {
@@ -43,6 +45,9 @@ export function GuestIdentityPopup({
}
const { id } = await res.json()
if (shareId) {
localStorage.setItem(`guest_user_id_${shareId}`, id)
}
localStorage.setItem('guest_user_id', id)
onSuccess(id)
onClose()