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
740
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
More Decks by Kazuki Miura
See All by Kazuki Miura
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
200
Kiro Crew で始める マルチエージェント開発
miu_crescent
PRO
1
250
Lambdaで動画のエンコードしたら MediaConvertに勝てるのか
miu_crescent
PRO
0
71
AWS Summit 報道現場で磨き上げた、 文字起こしシステムの開発。
miu_crescent
PRO
0
36
報道現場で磨き上げた、 ⽂字起こしシステムの開発
miu_crescent
PRO
0
37
地域のCCoEの拡大を目指す 企業間コミュニティ 「re:light local」について
miu_crescent
PRO
0
80
us-east-1 に障害が起きた時に、 ap-northeast-1 にどんな影響があるか 説明できるようになろう!
miu_crescent
PRO
13
5.3k
これだけはやっておいた方がよさそう?awsにおけるランサムウェア対策
miu_crescent
PRO
1
180
生成AIを活用した音声文字起こしシステムの2つの構築パターンについて
miu_crescent
PRO
4
500
Other Decks in Technology
See All in Technology
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
1
1.3k
What the customer really needed
kawaguti
PRO
1
160
山手線を徒歩で一周してわかった、 位置情報アプリは「足」が最強のデバッガー
hinakko
0
150
omasushiというライブラリを作った
polidog
PRO
0
230
LLMに渡さなかった仕事
nanaism
0
170
aws-iot-platform-architecture-use-cases.pdf
ma2shita
0
110
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
160
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
3
2.9k
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
740
AIによるクリエイティブ生成を行う上での試行錯誤
plaidtech
PRO
0
140
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
1
520
すぐできる衛星通信対応 あとは山奥に行くだけ
tatetate55
0
130
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Building an army of robots
kneath
307
46k
Claude Code のすすめ
schroneko
67
230k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Optimizing for Happiness
mojombo
378
71k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
A better future with KSS
kneath
240
18k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Balancing Empowerment & Direction
lara
6
1.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
4 Signs Your Business is Dying
shpigford
187
23k
Transcript
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 ଞʹ͍Ζ͍ΖͰ͖ΔΒ͍͠ʂ Έͳ͞Μɺͥͻ৮ͬͯΈ͍ͯͩ͘͞ʂ