Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Lambda@edgeで S3+CloudFrontで簡単BASIC認証!
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kazuki Miura
PRO
September 12, 2019
Technology
750
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Lambda@edgeで S3+CloudFrontで簡単BASIC認証!
20190912_JAWSUG札幌_LT1
Kazuki Miura
PRO
September 12, 2019
Transcript
21 slides
Lambda@edgeͰ S3+CloudFrontͰɺ؆୯BASICೝূʂ 20199݄12 ୈ24ճ JAWS-UG ࡳຈ
ࡾӜҰथ ωοτσδλϧࣄۀ෦ ͖ͳAWSαʔϏε:CloudFront ͖ͳGCPαʔϏε:BigQuery
ݱ͔ΒώΞϦϯά ༁ɾ࣮ґཔ ςΫχΧϧσΟϨΫλʔʁ 43& 1.ʁ
Lambda@edge ͬͯͳʹʁ
S3 bucket CloudFront Client Linuxͱ͔ͪΐͬͱΘ͔Μͳ͍ͷͰɺ web্ཱͪ͛Α͏ͱ͢Δͱɺ͜ͷํ๏͔͠Βͳ͍ͷͰ͢ɻ CloudFront େ͖
ʮ.htaccess ͱ͔Ͳ͏͢Μͷʁʯ
ͪΐͬͱɺΘ͔Μͳ͍
S3 bucket CloudFront Client Lambda@edge BASICೝূ
Ϧʔδϣϯ όʔδχΞ෦
Node.jsͷ߹
ʮsite:dev.classmethod.jp lambda BASICೝূʯ Ͱάάͬͯɺίϐϖ https://dev.classmethod.jp/cloud/aws/basic-auth-s3-cloudfront-lambda/
'use strict'; exports.handler = (event, context, callback) => { //
Get request and request headers const request = event.Records[0].cf.request; const headers = request.headers; // Configure authentication const authUser = 'user'; const authPass = 'pass'; // Construct the Basic Auth string const authString = 'Basic ' + new Buffer(authUser + ':' + authPass).toString('base64'); // Require Basic authentication if (typeof headers.authorization == 'undefined' || headers.authorization[0].value != authString) { const body = 'Unauthorized'; const response = { status: '401', statusDescription: 'Unauthorized', body: body, headers: { 'www-authenticate': [{key: 'WWW-Authenticate', value:'Basic'}] }, }; callback(null, response); } // Continue request processing if authentication passed callback(null, request); };
'use strict'; exports.handler = (event, context, callback) => { //
Get request and request headers const request = event.Records[0].cf.request; const headers = request.headers; // Configure authentication const authUser = 'user'; const authPass = 'pass'; // Construct the Basic Auth string const authString = 'Basic ' + new Buffer(authUser + ':' + authPass).toString('base64'); // Require Basic authentication if (typeof headers.authorization == 'undefined' || headers.authorization[0].value != authString) { const body = 'Unauthorized'; const response = { status: '401', statusDescription: 'Unauthorized', body: body, headers: { 'www-authenticate': [{key: 'WWW-Authenticate', value:'Basic'}] }, }; callback(null, response); } // Continue request processing if authentication passed callback(null, request); }; ͚ͩ͜͜ɺม͑Δ
ࠓΞΫγϣϯΛԡ͢ ϙνο
෦όʔδχΞ͚ͩʮػೳʯͬͯͷ͕͋Δ ෦όʔδχΞ ౦ژ
Πϕϯτશ෦Ͱ4छྨ ࠓճʮϏϡʔΞʔϦΫΤετʯΛબ
ͪΐͬͱɺͭ
σϓϩΠυ
CloudFrontͷBehaviorͷԼͷํ ͏·͘ɺͰ͖ͯͦ͏
ΞΫηεͯ͠ΈΔ Ͱ͖ͨʂʂ
Lambda@edge ଞʹ͍Ζ͍ΖͰ͖ΔΒ͍͠ʂ Έͳ͞Μɺͥͻ৮ͬͯΈ͍ͯͩ͘͞ʂ
More Decks by Kazuki Miura
See All by Kazuki Miura
AWS Well-Arhitected Frameworkセキュリティの柱 について
miu_crescent
PRO
2
270
アクシズへの第二次攻撃における3段構えとは一体なんだったのか
miu_crescent
PRO
0
380
田んぼから始まる挑戦 〜新米農家の1年目〜
miu_crescent
PRO
0
510
re:Invent の去年のスケジュールを公開します!
miu_crescent
PRO
0
430
ラスベガスで道民会を実施してる話。あとヌードルアジア。
miu_crescent
PRO
0
730
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
270
Kiro Crew で始める マルチエージェント開発
miu_crescent
PRO
1
330
Lambdaで動画のエンコードしたら MediaConvertに勝てるのか
miu_crescent
PRO
0
110
AWS Summit 報道現場で磨き上げた、 文字起こしシステムの開発。
miu_crescent
PRO
0
64
Other Decks in Technology
See All in Technology
みん強Lightning! データ基盤ひとりでできるかな
endonanana
0
230
現地速報! Microsoft Ignite アップデートレポート
kasada
1
740
専門家に使ってもらうAIプロダクトをつくる - 病院の医事課向けDPCコーディング支援システムの設計と評価
hagino3000
4
1.1k
リリースしたで終わらない。 観測できるフロントエンド開発
yamakenji24
4
1.9k
Fukurou Labo_Engineer_Deck
fukuroulabo
0
120
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
280
Amazon Bedrock AgentCore の基礎とセキュリティ・ガバナンス
ren8k
0
290
40以上のマイクロサービスを支えるKubernetes JITアクセス — 160以上の恒久RoleBindingを削減
jumpe1
0
120
OWASP AI Agentic Top10に準拠するクラウドネイティブなガードレールの実践(CNDW 2026)
keitah
1
460
Test Impact Analysis を武器に立ち向かう、AI 時代のテスト増加に対するヌーラボのアプローチ / getting-started-datadog-test-impact-analysis
k6s4i53rx
3
910
Well, that’s weird…
csswizardry
3
260
PMの私の 最近のAgent Skills活用法
haru860
0
110
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.5k
[SF Ruby Conf 2025] Rails X
palkan
3
1.6k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
350
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
580
Become a Pro
speakerdeck
PRO
31
6.4k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
890
Un-Boring Meetings
codingconduct
0
510
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
390
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
760
How to make the Groovebox
asonas
2
2.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k