2014年5月20日 星期二

網路服務第三方認證

OAUTH (http://oauth.net/) - An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications.

Yahoo OAuth (https://developer.yahoo.com/oauth/guide/oauth-guide.html)

一步一步搭建OAuth認證伺服器 
-- http://fecbob.pixnet.net/blog/post/38124119-%5Bphp%5D-%E4%B8%80%E6%AD%A5%E4%B8%80%E6%AD%A5%E6%90%AD%E5%BB%BAoauth%E8%AA%8D%E8%AD%89%E4%BC%BA%E6%9C%8D%E5%99%A8

Authorization for Google Services
-https://developers.google.com/apps-script/guides/services/authorization

OAuth - Open Authorization 開放式授權協定

http://blog.masterstudio101.com/2013/04/24/OAuth%20-%20Open%20Authorization%20%E9%96%8B%E6%94%BE%E5%BC%8F%E6%8E%88%E6%AC%8A%E5%8D%94%E5%AE%9A


詳細RFC6749內容請參考 http://tools.ietf.org/html/rfc6749

下面列出知名網站的OAuth 2.0的網址(URLs)
Google
  https://accounts.google.com/o/oauth2/auth
  https://accounts.google.com/o/oauth2/token
  https://www.googleapis.com/oauth2/v1
Facebook
  https://www.facebook.com/dialog/oauth
  https://graph.facebook.com/oauth/access_token
  https://graph.facebook.com
StackExchange (https://api.stackexchange.com/docs/authentication)
  https://stackexchange.com/oauth
  https://stackexchange.com/oauth/access_token
  https://api.stackexchange.com/2.0
Github
  https://github.com/login/oauth/authorize
  https://github.com/login/oauth/access_token
  https://api.github.com


另外補充, OAuth與OpenID (Google, PayPal, VeriSign)最大不同在於, OAuth是進行資源的授權(Authorization), 而OpenID是進行身份的驗證(Authentication), 兩者並不衝突更可予以整合應用, 有關OpenID細節容study後再分享. 

Reference 參考資料:
OAuth協定與運作流程 http://cire.pixnet.net/blog/post/308107... 
OAuth和OpenID http://sinkwung.blogspot.tw/... 
OAuth 參數說明 http://www.dotblogs.com.tw/regionbbs/... 

Resources 資源:
OAuth 官方網站 http://oauth.net/ 
OAuth 2.0官方網站 http://oauth.net/2 
RFC6749 http://tools.ietf.org/html/rfc6749
Yahoo Developer Network http://developer.yahoo.com
StackExchange OAuth https://api.stackexchange.com/docs/authentication  
Using OAuth 2.0 to access Google APIhttps://developers.google.com/accounts/docs/OAuth2  
Facebook Authenticationhttps://developers.facebook.com/docs/authentication
Windows Live oAuth 2.0 http://msdn.microsoft.com/en-us/library/live/hh243647.aspx 
Wiki OAuth http://zh.wikipedia.org/wiki/OAuth 
  • 漫談OAuth認證協定與運作流程 
  • - http://cire.pixnet.net/blog/post/30810748-%E6%BC%AB%E8%AB%87oauth%E8%AA%8D%E8%AD%89%E5%8D%94%E5%AE%9A%E8%88%87%E9%81%8B%E4%BD%9C%E6%B5%81%E7%A8%8B

2014年5月5日 星期一

ubuntu如何備份和恢復

source: http://www.itkee.com/os/detail-1476.html

 在 使用Ubuntu之前,相信很多人都有過使用Windows系統的經歷。如果你備份過Windows系統,那麼你一定記憶猶新:首先需要找到一個備份工 具(通常都是私有軟件),然後重啓電腦進入備份工具提供的軟件環境,在這裏備份或者恢復Windows系統。Norton Ghost是備份Windows系統時經常使用的備份工具。
在備份Windows系統的時候你可能想過,我能不能把整個C盤都放到一個ZIP文件裏去呢。這在Windows下是不可能的,因爲在Windows中有很多文件在它們運行時是不允許拷貝或覆蓋的,因此你需要專門的備份工具對Windows系統進行特殊處理。
和 備份Windows系統不同,如果你要備份Ubuntu系統(或者其它任何Linux系統),你不再需要像Ghost這類備份工具。事實上,Ghost 這類備份工具對於Linux文件系統的支持很糟糕,例如一些Ghost版本只能完善地支持Ext2文件系統,如果你用它來備份Ext3文件系統,你可能會 丟失一些寶貴的數據。
1. 備份系統
我該如何備份我的Ubuntu系統呢?很簡單,就像你備份或壓縮其它東西一樣,使用TAR。和Windows不同,Linux不會限制root訪問任何東西,你可以把分區上的所有東西都扔到一個TAR文件裏去!
首先成爲root用戶:
$ sudo su
然後進入文件系統的根目錄(當然,如果你不想備份整個文件系統,你也可以進入你想要備份的目錄,包括遠程目錄或者移動硬盤上的目錄):
# cd /
下面是我用來備份系統的完整命令:
# tar cvpzf backup.tgz Cexclude=/proc Cexclude=/lost+found Cexclude=/backup.tgz Cexclude=/mnt Cexclude=/sys /
讓我們來簡單看一下這個命令:
“tar”當然就是我們備份系統所使用的程序了。
“cvpfz”是tar的選項,意思是“創建檔案文件”、“保持權限”(保留所有東西原來的權限)、“使用gzip來減小文件尺寸”。
“backup.gz”是我們將要得到的檔案文件的文件名。
“/”是我們要備份的目錄,在這裏是整個文件系統。
在 檔案文件名“backup.gz”和要備份的目錄名“/”之間給出了備份時必須排除在外的目錄。有些目錄是無用的,例如“/proc”、“/lost+ found”、“/sys”。當然,“backup.gz”這個檔案文件本身必須排除在外,否則你可能會得到一些超出常理的結果。如果不把“/mnt”排 除在外,那麼掛載在“/mnt”上的其它分區也會被備份。另外需要確認一下“/media”上沒有掛載任何東西(例如光盤、移動硬盤),如果有掛載東西, 必須把“/media”也排除在外。
有人可能會建議你把“/dev”目錄排除在外,但是我認爲這樣做很不妥,具體原因這裏就不討論了。
執行備份命令之前請再確認一下你所鍵入的命令是不是你想要的。執行備份命令可能需要一段不短的時間。
備份完成後,在文件系統的根目錄將生成一個名爲“backup.tgz”的文件,它的尺寸有可能非常大。現在你可以把它燒錄到DVD上或者放到你認爲安全的地方去。
在備份命令結束時你可能會看到這樣一個提示:’tar: Error exit delayed from previous errors’,多數情況下你可以忽略它。
你還可以用Bzip2來壓縮文件,Bzip2比gzip的壓縮率高,但是速度慢一些。如果壓縮率對你來說很重要,那麼你應該使用Bzip2,用“j”代替命令中的“z”,並且給檔案文件一個正確的擴展名“bz2”。完整的命令如下:
# tar cvpjf backup.tar.bz2 Cexclude=/proc Cexclude=/lost+found Cexclude=/backup.tar.bz2 Cexclude=/mnt Cexclude=/sys /
2. 恢復系統
在進行恢復系統的操作時一定要小心!如果你不清楚自己在做什麼,那麼你有可能把重要的數據弄丟,請務必小心!
接着上面的例子。切換到root用戶,並把文件“backup.tgz”拷貝到分區的根目錄下。
在 Linux中有一件很美妙的事情,就是你可以在一個運行的系統中恢復系統,而不需要用boot-cd來專門引導。當然,如果你的系統已經掛掉不能啓動了, 你可以用Live CD來啓動,效果是一樣的。你還可以用一個命令把Linux系統中的所有文件幹掉,當然在這裏我不打算給出這個命令!
使用下面的命令來恢復系統:
# tar xvpfz backup.tgz -C /
如果你的檔案文件是使用Bzip2壓縮的,應該用:
# tar xvpfj backup.tar.bz2 -C /
注意:上面的命令會用檔案文件中的文件覆蓋分區上的所有文件。
執行恢覆命令之前請再確認一下你所鍵入的命令是不是你想要的,執行恢覆命令可能需要一段不短的時間。
恢覆命令結束時,你的工作還沒完成,別忘了重新創建那些在備份時被排除在外的目錄:
# mkdir proc
# mkdir lost+found
# mkdir mnt
# mkdir sys
等等
當你重啓電腦,你會發現一切東西恢復到你創建備份時的樣子了!


http://blog.riaproject.com/server-setting/1305/%E7%B0%A1%E6%98%93%E5%82%99%E4%BB%BDubuntu%E7%B3%BB%E7%B5%B1%E7%9A%84%E6%96%B9%E6%B3%95.html

方法2: 用Sbackup軟體來做

用GUI介面是對指令模式非常排斥,或是懶人所設計的,
其實所做的工作跟方法1是相同的,
只是這次多了UI介面給你用,點一點按一按就可以了。
sbackup

2014年3月30日 星期日

防火牆技術

穿越防火牆技術

1. (穿越防火牆技術) http://www.cs.nccu.edu.tw/~lien/Writing/NGN/firewall.htm
2. Libnice (http://nice.freedesktop.org/wiki/)
3. PJNATH - Open Source ICE, STUN, and TURN Library (http://www.pjsip.org/pjnath/docs/html/index.htm)
4. The TCP/IP guide (http://www.tcpipguide.com/free/t_IPNetworkAddressTranslationNATProtocol.htm)
5.NAT Traversal and Peer to Peer (http://lab.howie.tw/2012/07/Peer-to-Peer-and-NAT-Traversal.html)
6.



Code Reference
1. Google libjingle (https://developers.google.com/talk/libjingle/?hl=zh-TW&csw=1)
2. STUNT (http://nutss.gforge.cis.cornell.edu/jstunt-examples.php)
3. PJNATH (http://www.pjsip.org/pjnath/docs/html/index.htm)

Difference Between NAT and Proxy

Source: http://www.differencebetween.com/difference-between-nat-and-vs-proxy/

NAT vs Proxy 
Network Address Translation (NAT) is the process that modifies the IP address in a header of an IP packet, while it is travelling through a routing device. NAT allows one set of IP addresses to be used for traffic within a LAN (Local Area Network) and another set of IP addresses for outside traffic. One to one transformation of IP addresses are provided by the simplest form of NAT. Proxy (proxy server) is a server that is located between a client (who is looking for a resource) and some other server and acts as a mediator. The client requesting the resource connects to the proxy server and the proxy evaluates the request based on its filtering rules.

What is NAT?
NAT modifies IP address in a header of an IP packet, while it is travelling through a routing device. NAT allows one set of IP addresses to be used for traffic within a LAN and another set of IP addresses for outside traffic. One to one transformation of IP addresses are provided by the simplest form of NAT. NAT has several advantages. It improves the security of a LAN since it provides the option to hide internal IP addresses. Furthermore, as the IP addresses are only used internally, it will not cause any conflicts with IP addresses used in other organizations. Also, using a single internet connection for all the computers in a LAN is made possible by NAT. NAT works with the use of a NAT box, which is situated in the interface where the LAN is connected to the internet. It contains a set of valid IP addresses and it is responsible for performing the IP address translations.

What is a Proxy?
Proxy is a server that is located between a client (that is looking for a resource) and some other server and acts as a mediator. The client requesting the resource connects to the proxy server and the proxy evaluates the request based on its filtering rules. If the request is validated, proxy connects to the server and provides the requested resource to the client. On the other hand, proxy may satisfy the client’s request without going to the specified server. For this, the proxy uses a cache and any of the subsequent requests for the same resource are satisfied without contacting the specified server. Due to this, proxies can improve the performance greatly. Furthermore, proxies can be used to filter requests and prevent accessing some web sites.

What is the difference between NAT and Proxy?
NAT modifies IP address in a header of an IP packet, while it is travelling through a routing device and allows to use a different set of IP addresses for traffic within a LAN than the set of IP addresses for outside traffic, while a proxy is a server that is located between a client and some other server and acts as a mediator. NAT does not need any special application software to operate, whereas applications behind a proxy server must support proxy services and should be configured to use the proxy server.


Read more: http://www.differencebetween.com/difference-between-nat-and-vs-proxy/#ixzz2xVQ3TG5i

2014年1月27日 星期一

Ubuntu 遠端桌面畫面問題

Source:http://blog.snowtec.org/2009/05/ubuntu-904-vnc-problem/

Ubuntu內建了遠端桌面功能 (也就是VNC Server),在「系統→偏好設定→遠端桌面」可以進行開啟與其他設定。
不過最近我遇到了一個相當奇怪的Bug…連線成功之後,系統卻不會將畫面更新,總是停留在第一個畫格。雖然動作事件都有送到被控端,但在看不到螢幕反應的情況下使用上實在是有點…不,是十分困難啊!遇到這種事情當然我們還是要求助於Google大神,然後很幸運的我得到了解答。
這個Bug的發生時機是,你使用nVidia的顯示卡,然後也啟用了Compiz (也就是桌面特效)。Xwindow有個功能叫XDamage,在做VNC連線時可以只傳送桌面上改變的部份的畫面 (例如,你移動的視窗),進而減少使用網路傳輸量。但不知為什麼,遇到受限制的nVidia驅動程式加上Compiz,這個功能就會壞掉,變成client一旦連上之後畫面就不會更新,永遠卡在第一個frame。
在 Launchpad 已經有網友提出這個bug,也已經有解決辦法了。
解決方案有:
  1. 不使用VNC。 (這…)
  2. 完全關閉桌面特效。
    ubuntu桌面特效
  3. 使用別的VNC軟體,例如:x11vnc:
    $ sudo apt-get install x11vnc
    $ x11vnc –noxdamage –passwd 密碼 -forever
  4. 安裝修正包:
    Launchpad上已經放出了修正過後的Vino (內建的VNC Server),到 這裡 可以下載更新過後的版本。
    安裝完畢之後,按「Alt+F2」執行「gconf-editor」,把鍵值
    「/desktop/gnome/remote_access/disable_xdamage」修改為true (勾起來的意思),再到選單中啟動遠端桌面。
    gconfeditor遠端連線修改
雖然說這樣會影響連線品質,不過目前似乎是沒有更好的解法,我也不敢保證我的是最好最恰當的解法,所以如果有什麼意見的話也歡迎留言跟我說。
到這裡你的VNC應該就可以順利、快樂、至少不會停格的連線了。

2014年1月5日 星期日

3C應用

1. 你的手機就是最高檔的行車記錄器

2. 只是手寫何必買 Wacom?手機免費變身無線手寫板!
3. 將#可穿戴設備#與汽車駕駛結合起來,現代汽車正開發一款#Google Glass#應用來操控汽車
4. HTC Mini+ – 超越配件等級的多功能智慧小手機
7. 輕便旅行隨身好物 i-FlashDrive雙頭龍Android特別版
8. Smart Sign Language Interpreter智慧型手語翻譯 聽障人士代言人
9. 2014 CES 大預測:別管 Google Glass 了,穿戴式科技大舉入侵健康照護和健身領域!
10. Google再次聚焦家庭能源使用的追踪,正在測試連接到網絡的智能恆溫器
11. 想讓傳統家電變智能?只需配一個智能插座就行!Plugaway 推智能插座及智能LED燈