HomeArtTechHackBlockchain
ONLINE ·
Index
/
Hack101
/
Article

Security Header

Operator
Khomkrid Lerdprasert
Filed
September 03, 2020
Channel
Hack101
Read
~1 min
Security Header

Security Header

มาทำ Security header ให้ firebase hosting ให้ได้ rang A กันเถอะ

โดยเราจะเข้าไป check ranking ได้จาก website “securityheaders”

securityheaders
securityheaders

เริ่มจากเกิดความสงสัยว่า เอ้ย ถ้าเราใช้ firebase hosting เนี่ย จะตั้งค่า security header ยังไงหว่า

เพราะลองเอาเวปตัวเองไป check บน “securityheaders” พบว่าได้ rank F แล้วจะทำยังไงดีให้มันได้ rank A

ก็ต้องไปตามแก้ ตาม list นี้ให้หมด

  1. Strict-Transport-Security
  2. Content-Security-Policy
  3. X-Frame-Options
  4. X-Content-Type-Options
  5. Referrer-Policy
  6. Feature-Policy

โดยเราจะไปเพิ่ม header ในไฟล์ firebase.json อยากเพิ่มอะไร ก็ไปจัดการข้างในได้เลย

{
"hosting": {
"headers": [
{
"source": "**",
"headers": [
{
"key": "Content-Security-Policy",
"value": "script-src 'self' www.google-analytics.com"
},
{
"key": "Content-Security-Policy",
"value": "font-src 'self' fonts.gstatic.com"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "Referrer-Policy",
"value": "no-referrer-when-downgrade"
},
{
"key": "Feature-Policy",
"value": "document-domain 'self'"
}
]
}
],
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
}
}

เพิ่มเสร็จแล้วทำการ

firebase deploy --only hosting

เป็นอันจบ ก็จะได้ rank A มาเรียบร้อยยยยยยยยยยยยยย

securityheaders
securityheaders

◎ Tags

##sercurity##firebase##firebase hosting
Khomkrid Lerdprasert
Operator

Khomkrid Lerdprasert

Technical Lead — building AI-powered platforms, omni-channel chat systems, and telemedicine solutions with Go, Next.js & clean architecture. 20+ years shipping software from crypto wallets to e-learning systems. Bangkok-based. Writes code late at night, brews beer on weekends.

GithubInstagram
Previous · transmission
Stored Cross Site Scripting (XSS)
Next · transmission
Content Security Policy By Pass
Metadata
Channel
Hack101
Filed
September 03, 2020
Read
~1 min
Language
TH / EN
Transmit

Related

Content Security Policy By Pass
Khomkrid Lerdprasert
September 04, 2020
2 min
aofiee.dev
signal / noise / code · craft
© 2019 – 2026, Khomkrid Lerdprasert.
All transmissions logged.
No newsletter. No profiling. Cookies require consent.
PGP · 7F3D 2024 A21E B584 · 0x7F3D
Channels
  • Art & Culture
  • Technology
  • Hack 101
  • Blockchain 101
  • Archive / All posts
— END OF TRANSMISSION —
// powered by curiosity, coffee, & wuxia
BKK · 13°45′N · 100°30′E