opensocialのアーキテクチャ
TRANSCRIPT
![Page 1: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/1.jpg)
OpenSocialのアーキテクチャ
えーじ
1
![Page 2: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/2.jpg)
自己紹介 • 北村英志 (id: agektmr)
‒ NTTレゾナント株式会社(gooホーム) ‒ Google API Expert (OpenSocial) ‒ Shindig committer ‒ SocialWeb Japan主催 ‒ ブログ: Tender Surrender http://devlog.agektmr.com/
2
![Page 3: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/3.jpg)
OpenSocial
3
![Page 4: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/4.jpg)
OpenSocialアプリとは?
4
![Page 5: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/5.jpg)
成り立ち • 2007年11月 Google Campfireで発表 • MySpace、hi5、orkutといった米国大手のSNSが賛同
• Googleの先導で始まったものの、現在はOpenSocial Foundationが取りまとめている
5
![Page 6: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/6.jpg)
特徴 • オープンな仕様
‒ Learn Once, Write Anywhere • オープンな仕様作成プロセス
‒ http://groups.google.com/group/opensocial • 豊富な関連オープンソースプロダクト
‒ Apache Shindig ‒ OpenSocial Client Libraries ‒ OpenSocial Development Environment ‒ OpenSocial‒jQuery ‒ etc.
6
![Page 7: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/7.jpg)
仕様策定プロセス • オープンなメーリングリストで議論 • 誰でも仕様の提案が可能 • 仕様について議論 • 投票 • Apache Shindigで実装 • 仕様完成
7
![Page 8: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/8.jpg)
OpenSocialの仕様
8
![Page 9: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/9.jpg)
2つの側面
• JavaScript API (ガジェットプラットフォーム) ‒ SNS内に埋め込むアプリケーション
• RESTful API (外部サーバー連携) ‒ SNS外にソーシャルグラフを提供
9
![Page 10: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/10.jpg)
OpenSocialガジェットでできること
• HTML, CSS, JavaScript, Flash等を使った、SNS上で動作するアプリケーションの開発
• ソーシャルグラフの取得 • プロフィールの取得 • アクティビティの送信、取得 • アプリデータの保存、取得 • メッセージの送信 • 外部サーバーとの通信 • etc.
10
![Page 11: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/11.jpg)
ガジェットの作り方
11
![Page 12: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/12.jpg)
手順 1. XMLファイルを書く 2. ウェブサーバーにアップロード 3. OpenSocialコンテナに登録 4. ガジェットを表示
12
![Page 13: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/13.jpg)
XMLファイルの構成 • メタ情報
‒ ガジェット名 ‒ 概要 ‒ 利用する機能(feature) ‒ その他設定、定義
• ガジェットの表示内容 ‒ ビューごとに指定 ‒ HTML, CSS, JavaScript, Flash, etc.を記述
13
![Page 14: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/14.jpg)
OpenSocialのガジェットXML <?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="タイトル" description="概要文" author="Eiji
Kitamura" author_email="[email protected]" > <Require feature="opensocial-0.8" /> <Require feature="dynamic-height" /> </ModulePrefs> <Content type="html" view="canvas"> <![CDATA[ ガジェットに表示するソースコード ]]> </Content> </Module>
14
![Page 15: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/15.jpg)
サーバーにアップロード • Webサーバー • Google AppEngine • Dropbox
15
![Page 16: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/16.jpg)
OpenSocialコンテナに登録
16
mixiアプリ
gooホーム
![Page 17: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/17.jpg)
ガジェットを表示
17
![Page 18: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/18.jpg)
ガジェットはどうやって表示されているのか?
18
![Page 19: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/19.jpg)
ブログパーツ?
19
![Page 20: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/20.jpg)
XSSを避ける4つの方法 • ドメインを分ける • 安全性の確認されたJavaScriptのみ許可する • JavaScriptの危険な部分のみ無力化する(Caja) • iframeで表示する
20
![Page 21: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/21.jpg)
ShindigでのGadget表示方法
21
![Page 22: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/22.jpg)
iframe対応による課題 • 認証方法 • コンテナとShindigの通信方法 • 外部サーバーとの通信方法 • セキュリティ
22
![Page 23: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/23.jpg)
OpenSocialアーキテクチャ
23
Shindig Container
Browser
Gadget
opensocial gadgets
Database
proxy json-rpc
metadata
External Service
Gadget XML
SNS
![Page 24: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/24.jpg)
ガジェットが表示されるまで
24
![Page 25: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/25.jpg)
1. ブラウザからSNSにアクセス
25
Shindig Container
Browser
Database External Service
Gadget XML
![Page 26: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/26.jpg)
2. ガジェットに関する情報を収集
26
Shindig Container
Browser
Database
metadata
External Service
Gadget XML
![Page 27: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/27.jpg)
3. SNSをレンダリング
27
Shindig Container
Browser
Database External Service
Gadget XML
SNS
![Page 28: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/28.jpg)
4. iframeにガジェットをレンダリング
28
Shindig Container
Browser
Gadget
Database External Service
Gadget XML
SNS Token
![Page 29: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/29.jpg)
5. iframeにガジェットをレンダリング
29
Shindig Container
Browser
Gadget
Database External Service
Gadget XML
SNS
![Page 30: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/30.jpg)
OpenSocial APIを使う
30
![Page 31: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/31.jpg)
OpenSocial APIを使う
31
Shindig Container
Browser
Gadget
opensocial
Database
json-rpc
External Service
Gadget XML
SNS Token
![Page 32: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/32.jpg)
外部サーバーと通信する
32
![Page 33: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/33.jpg)
外部サーバーとの通信
33
Shindig Container
Browser
Gadget
gadgets
Database
proxy
External Service
Gadget XML
SNS
![Page 34: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/34.jpg)
Signed Request • 別名OAuth Consumer Request、2 Legged OAuth
• ガジェットが外部サーバーと通信する際のオプション
• リクエストに署名を付け加えることができる • 外部サーバーは、署名を元にリクエスト内容が改ざんされていないかチェック可能
34
![Page 35: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/35.jpg)
ケース1
• 無関係なガジェットやサーバーからデータを書き換えられる
35
Evil External Service
悪意のあるサーバー
![Page 36: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/36.jpg)
ケース2
• GreaseMonkey等を使って他人に成り済まされる
36
Shindig
Browser
Gadget
gadgets proxy External Service
悪意のあるスクリプト
![Page 37: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/37.jpg)
ケース3
• 通信途中のノードでリクエストを書き換えられる
37
Shindig
Browser
Gadget
gadgets proxy External Service
悪意のある仲介者
![Page 38: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/38.jpg)
Signed Requestで解決
• サーバーで正確な情報を追加 ‒ opensocial_viewer_id ‒ opensocial_owner_id ‒ opensocial_app_url
• 電子署名を追加 38
Shindig
Browser
Gadget
gadgets proxy External Service ............ ....... ............ .........
![Page 39: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/39.jpg)
OAuth • ガジェットが外部サーバーと通信する際のオプション
• 外部サーバーの認証の仕組みを使い、ガジェットが認可を得ることができる
• OAuth Proxy
39
![Page 40: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/40.jpg)
OAuthを用いないマッシュアップ
• ユーザーは信頼できるとは限らないアプリケーションに、サービスのクレデンシャル(ID/Pass)を預けざるを得なかった
40
Application Browser Service
ID/Pass
![Page 41: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/41.jpg)
一般的なOAuth
41
Application Browser Service
ユーザー コンシューマ サービスプロバイダ
ID/Pass Token
![Page 42: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/42.jpg)
OpenSocialにおける OAuth Proxy
42
Shindig
Browser
Gadget
gadgets proxy External Service
ユーザー コンシューマ サービスプロバイダ コンシューマ?
ID/Pass Token
![Page 43: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/43.jpg)
OpenSocialアーキテクチャ
43
Shindig Container
Browser
Gadget
opensocial gadgets
Database
proxy json-rpc
metadata
External Service
Gadget XML
SNS
![Page 44: OpenSocialのアーキテクチャ](https://reader034.vdocuments.pub/reader034/viewer/2022042614/558a5510d8b42a851e8b4682/html5/thumbnails/44.jpg)
最後に • 現在日本のOpenSocialコンテナはgoo、mixi • 既にDeNA、リクルートが対応を表明 • smart.fmも対応予定
44
日本のソーシャルウェブを 盛り上げて行きましょう!