SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
淺談 RESTful API 認證
Token 機制使用經驗分享
RESTful API Authentication
Cobalt Chang
Outline
❖HTTP Protocol
❖Stateless Connections
❖JWT v.s. DRF Token
❖Djoser
❖Atlas – NEXCOM Embedded System
❖應用於 Web 服務
➢ 符合 REST 設計風格的 Web API
➢ 直觀簡短的資源地址: URI ,比如: http://example.com/resources/ 。
➢ 傳輸的資源: Web 服務接受與返回的網際網路媒體類型, JSON , XML , YAML 等。
➢ 對資源的操作: Web 服務在該資源上所支持的一系列請求方法。
GET PUT POST DELETE
一組資源的 URI ,比如
http://api.example.com/resources/
列出 URI ,以及該資
源組中每個資源的詳
細資訊。
使用給定的一組資源
替換當前整組資源。
創建 / 追加一個新的
資源。該操作往往返
回新資源的 URL 。
刪除整組資源。
單個資源的 URI ,比如
http://api.example.com/resources/
item17/
獲取指定資源的詳細
資訊,格式可以是
XML 、 JSON 等。
替換 / 創建指定的資
源。
在指定的資源下創建
/ 追加一個新的元
素。
刪除指定的元素。
HTTP Protocol
❖REST, Representational State Transfer ( 具象狀態傳輸 )
➢ Roy Thomas Fielding 博士於 2000 年在他的博士論文中提出來的一種軟體架構風格。
➢ 應用程式的狀態跟功能拆成 resources
■ 每一個 resource 由一個 global identifier ( 即 URI) 所表示
➢ 資源的表現形式則是 XML 或者 HTML ,取決於讀者是機器還是人,當然也可以是任何其
他的格式。
➢ 所有 resources 共用一致的介面轉換狀態
■ 一組有限的良好定義操作 well-defined operations
RESTful API - REST
RESTful API - RESTful
❖REST 的要求:
➢ 使用者端 / 伺服器端 Client/Server
➢ 狀態無關 Stateless
➢ 可以快取 Cacheable
➢ 分層的 Layered
➢ 標準化的介面 Uniform interface
❖符合以上原則 (principles) 的系統稱做 RESTful 。
RESTful API - 有什麼優點
❖支援快取 caching 將改善反應時間跟 server 的負載能力。
❖因為不必維持連結狀態,大大改善 server 的 scalability 能力。這表示
不同 server 可以處理同一串 requests 。
❖一個瀏覽器就可以存取任一應用程式跟資源, client 端不需使用別的軟
體。
❖在 HTTP 之上不依存其他機制跟軟體。
❖跟其他連結方式相比 ( 如 RPC) ,可以提供相等的功能。
❖不需要其他的 discovery 機制,因為使用超連結了。
Session Connections
Stateful Connections
Stateless Connections
JSON Web Token (JWT)
JWT 特性
❖無法真正「登出」
➢ JWT 裡包含足夠的訊息可用來登入
➢ 只能將 Client 的 Cookie 刪除
❖維持連線 alive
➢ 有效時間內可拿舊 Token 換新 Token
➢ 設定長期間的 Token (14 天或 30 天 )
➢ 自己實作定期換 Token
Django REST Framework
❖使用 django REST framework (DRF) 來開發 RESTful APIs
❖DRF 提供三種認證機制
➢ BasicAuthentication
➢ SessionAuthentication
➢ TokenAuthentication
Token Authentication
❖Token 和 User 是一對一關係
➢ 同一個 Client 在多台機器上登入都會使用同一個 Token
➢ 將 Client 「登出」會將 Token 刪除
■ 其他機器的 Token 將無法再使用
❖除非從 Database 裡刪除 Token ,否則永久存在。
DRF Token 特性
❖使用 SSL 連線
❖使用 SSL 連線
❖使用 SSL 連線
安全性問題
❖實作 Django 認證系統的 REST 套件
❖利用 DRF 認證機制的第三方套件
❖Supported authentication backends
➢ HTTP Basic Auth ( 預設 )
➢ Token based authentication from Django Rest Framework
❖ 設定
➢ 帳號是否需要 activate
➢ 密碼是否需要再次輸入
Introduction to Djoser
❖提供的 APIs:
➢ /register/ 註冊
➢ /login/ 登入 (token based authentication)
➢ /logout/ 登出 (token based authentication)
➢ /password/ 更換密碼
➢ /password/reset/ 重設密碼 ( 發送 email)
➢ /password/reset/confirm/ 重設密碼 (email 裡的 link)
Djoser APIs
認證信功能
❖要求輸入註冊時的 email 而不是帳號
❖使用「加密」的 {uid} (base64 encode) 和 {token} (Django token)
➢ /password/reset/confirm/{uid}/{token}
➢ e.g. /password/reset/confirm/MQ/491-55796529106ab9437a42
❖可修改 email 的 template
❖使用 Django 的 urls 和 view 來產生重設密碼的頁面
我們正在打造的…
❖網通產品解決方案
❖Web based desktop
➢ 使用 Django 作為 Backend
➢ 透過 RESTful APIs 串接 AngularJS
➢ Single page application (SPA)
❖以套件管理為基礎的作業系統
❖跨平台的嵌入式系統
Single Page Application
PythonJavascript
DjangoAngularJS
$resource ($http)
Django REST
framework
RESTful API
(JSON)
HTML / CSS
Database
ORM
Front-end Back-end
Language Framework Module / App
21
Atlas
❖NEXCOM embedded system
❖完整的 Firmware ,包含
bootloader 、 kernel 、 rootfs 、
web GUI 等等。
kernel
bootloader
kernel
bootloader
kernel
bootloader
x86 ARM PowerPC
rootfs
DevOps
Thanks!
24

Contenu connexe

Tendances

An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourSoroush Dalili
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkChris Gates
 
MSBuild + Git + Jenkins
MSBuild + Git + JenkinsMSBuild + Git + Jenkins
MSBuild + Git + Jenkins선협 이
 
이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정Arawn Park
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해beom kyun choi
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우Arawn Park
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - IntroductionKnoldus Inc.
 
Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発Yuki Hattori
 
Spring Security
Spring SecuritySpring Security
Spring SecuritySumit Gole
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample applicationAntoine Rey
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCSuvash Shah
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...Altinity Ltd
 
Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Justin Lin
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data AccessDzmitry Naskou
 
Spring integration을 통해_살펴본_메시징_세계
Spring integration을 통해_살펴본_메시징_세계Spring integration을 통해_살펴본_메시징_세계
Spring integration을 통해_살펴본_메시징_세계Wangeun Lee
 

Tendances (20)

An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
MySQL on ZFS
MySQL on ZFSMySQL on ZFS
MySQL on ZFS
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit Framework
 
MSBuild + Git + Jenkins
MSBuild + Git + JenkinsMSBuild + Git + Jenkins
MSBuild + Git + Jenkins
 
이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정이벤트 기반 분산 시스템을 향한 여정
이벤트 기반 분산 시스템을 향한 여정
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해
 
코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우코틀린 멀티플랫폼, 미지와의 조우
코틀린 멀티플랫폼, 미지와의 조우
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発Microsoft Graph APIを活用した社内アプリケーション開発
Microsoft Graph APIを活用した社内アプリケーション開発
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVCCSRF Attack and Its Prevention technique in ASP.NET MVC
CSRF Attack and Its Prevention technique in ASP.NET MVC
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
 
Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器Spring 2.0 技術手冊第三章 - IoC 容器
Spring 2.0 技術手冊第三章 - IoC 容器
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
 
Spring integration을 통해_살펴본_메시징_세계
Spring integration을 통해_살펴본_메시징_세계Spring integration을 통해_살펴본_메시징_세계
Spring integration을 통해_살펴본_메시징_세계
 
CORS and (in)security
CORS and (in)securityCORS and (in)security
CORS and (in)security
 

Similaire à 淺談RESTful API認證 Token機制使用經驗分享

開放原始碼 Ch2.5 app - oss - 3rd party api(ver 1.0)
開放原始碼 Ch2.5   app - oss - 3rd party api(ver 1.0) 開放原始碼 Ch2.5   app - oss - 3rd party api(ver 1.0)
開放原始碼 Ch2.5 app - oss - 3rd party api(ver 1.0) My own sweet home!
 
Real time web实时信息流推送
Real time web实时信息流推送Real time web实时信息流推送
Real time web实时信息流推送yongboy
 
Real-Time Web实时信息流推送
Real-Time Web实时信息流推送Real-Time Web实时信息流推送
Real-Time Web实时信息流推送yongboy
 
用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Servicesjavatwo2011
 
Laradebut #7 - Laravel AUTH
Laradebut #7 - Laravel AUTHLaradebut #7 - Laravel AUTH
Laradebut #7 - Laravel AUTHSzuping Wang
 
Res tful api design tw-2.0
Res tful api design tw-2.0Res tful api design tw-2.0
Res tful api design tw-2.0昀陞 李
 
.NET Security Application/Web Development - Part II
.NET Security Application/Web Development - Part II.NET Security Application/Web Development - Part II
.NET Security Application/Web Development - Part IIChen-Tien Tsai
 
Ajax Lucence
Ajax LucenceAjax Lucence
Ajax LucenceRoger Xia
 
运维系统开发与Rails 3页面开发实践
运维系统开发与Rails 3页面开发实践运维系统开发与Rails 3页面开发实践
运维系统开发与Rails 3页面开发实践Li JianYe
 
用戶端攻擊與防禦
用戶端攻擊與防禦用戶端攻擊與防禦
用戶端攻擊與防禦Taien Wang
 
XMLHTTPRequest的属性和方法简介
XMLHTTPRequest的属性和方法简介XMLHTTPRequest的属性和方法简介
XMLHTTPRequest的属性和方法简介wensheng wei
 
Asp.net mvc 4 web api 開發簡介
Asp.net mvc 4 web api 開發簡介Asp.net mvc 4 web api 開發簡介
Asp.net mvc 4 web api 開發簡介Gelis Wu
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院Hu Kenneth
 
ASP.Net WebAPI經驗分享
ASP.Net WebAPI經驗分享ASP.Net WebAPI經驗分享
ASP.Net WebAPI經驗分享國昭 張
 
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Justin Lin
 

Similaire à 淺談RESTful API認證 Token機制使用經驗分享 (20)

開放原始碼 Ch2.5 app - oss - 3rd party api(ver 1.0)
開放原始碼 Ch2.5   app - oss - 3rd party api(ver 1.0) 開放原始碼 Ch2.5   app - oss - 3rd party api(ver 1.0)
開放原始碼 Ch2.5 app - oss - 3rd party api(ver 1.0)
 
Real time web实时信息流推送
Real time web实时信息流推送Real time web实时信息流推送
Real time web实时信息流推送
 
Real-Time Web实时信息流推送
Real-Time Web实时信息流推送Real-Time Web实时信息流推送
Real-Time Web实时信息流推送
 
Sse api
Sse apiSse api
Sse api
 
用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services用JAX-RS和Jersey完成RESTful Web Services
用JAX-RS和Jersey完成RESTful Web Services
 
Laradebut #7 - Laravel AUTH
Laradebut #7 - Laravel AUTHLaradebut #7 - Laravel AUTH
Laradebut #7 - Laravel AUTH
 
Intro to REST
Intro to RESTIntro to REST
Intro to REST
 
Intro to rest
Intro to restIntro to rest
Intro to rest
 
Res tful api design tw-2.0
Res tful api design tw-2.0Res tful api design tw-2.0
Res tful api design tw-2.0
 
Berserk js
Berserk jsBerserk js
Berserk js
 
.NET Security Application/Web Development - Part II
.NET Security Application/Web Development - Part II.NET Security Application/Web Development - Part II
.NET Security Application/Web Development - Part II
 
Ajax Lucence
Ajax LucenceAjax Lucence
Ajax Lucence
 
RESTful
RESTfulRESTful
RESTful
 
运维系统开发与Rails 3页面开发实践
运维系统开发与Rails 3页面开发实践运维系统开发与Rails 3页面开发实践
运维系统开发与Rails 3页面开发实践
 
用戶端攻擊與防禦
用戶端攻擊與防禦用戶端攻擊與防禦
用戶端攻擊與防禦
 
XMLHTTPRequest的属性和方法简介
XMLHTTPRequest的属性和方法简介XMLHTTPRequest的属性和方法简介
XMLHTTPRequest的属性和方法简介
 
Asp.net mvc 4 web api 開發簡介
Asp.net mvc 4 web api 開發簡介Asp.net mvc 4 web api 開發簡介
Asp.net mvc 4 web api 開發簡介
 
20201006 meta_coin 六角學院
20201006 meta_coin 六角學院20201006 meta_coin 六角學院
20201006 meta_coin 六角學院
 
ASP.Net WebAPI經驗分享
ASP.Net WebAPI經驗分享ASP.Net WebAPI經驗分享
ASP.Net WebAPI經驗分享
 
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
 

Plus de Tun-Yu Chang

Development environment
Development environmentDevelopment environment
Development environmentTun-Yu Chang
 
改變未來的物聯網
改變未來的物聯網改變未來的物聯網
改變未來的物聯網Tun-Yu Chang
 
What are programs? 兼談現代化軟體開發
What are programs? 兼談現代化軟體開發What are programs? 兼談現代化軟體開發
What are programs? 兼談現代化軟體開發Tun-Yu Chang
 
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌Tun-Yu Chang
 
Auth of restful_api
Auth of restful_apiAuth of restful_api
Auth of restful_apiTun-Yu Chang
 

Plus de Tun-Yu Chang (6)

Development environment
Development environmentDevelopment environment
Development environment
 
改變未來的物聯網
改變未來的物聯網改變未來的物聯網
改變未來的物聯網
 
A.I. And I
A.I. And IA.I. And I
A.I. And I
 
What are programs? 兼談現代化軟體開發
What are programs? 兼談現代化軟體開發What are programs? 兼談現代化軟體開發
What are programs? 兼談現代化軟體開發
 
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌
哥寫的不是程式,是軟體 - 從嵌入式系統看軟體工程全貌
 
Auth of restful_api
Auth of restful_apiAuth of restful_api
Auth of restful_api
 

淺談RESTful API認證 Token機制使用經驗分享

  • 1. 淺談 RESTful API 認證 Token 機制使用經驗分享 RESTful API Authentication Cobalt Chang
  • 2. Outline ❖HTTP Protocol ❖Stateless Connections ❖JWT v.s. DRF Token ❖Djoser ❖Atlas – NEXCOM Embedded System
  • 3. ❖應用於 Web 服務 ➢ 符合 REST 設計風格的 Web API ➢ 直觀簡短的資源地址: URI ,比如: http://example.com/resources/ 。 ➢ 傳輸的資源: Web 服務接受與返回的網際網路媒體類型, JSON , XML , YAML 等。 ➢ 對資源的操作: Web 服務在該資源上所支持的一系列請求方法。 GET PUT POST DELETE 一組資源的 URI ,比如 http://api.example.com/resources/ 列出 URI ,以及該資 源組中每個資源的詳 細資訊。 使用給定的一組資源 替換當前整組資源。 創建 / 追加一個新的 資源。該操作往往返 回新資源的 URL 。 刪除整組資源。 單個資源的 URI ,比如 http://api.example.com/resources/ item17/ 獲取指定資源的詳細 資訊,格式可以是 XML 、 JSON 等。 替換 / 創建指定的資 源。 在指定的資源下創建 / 追加一個新的元 素。 刪除指定的元素。 HTTP Protocol
  • 4. ❖REST, Representational State Transfer ( 具象狀態傳輸 ) ➢ Roy Thomas Fielding 博士於 2000 年在他的博士論文中提出來的一種軟體架構風格。 ➢ 應用程式的狀態跟功能拆成 resources ■ 每一個 resource 由一個 global identifier ( 即 URI) 所表示 ➢ 資源的表現形式則是 XML 或者 HTML ,取決於讀者是機器還是人,當然也可以是任何其 他的格式。 ➢ 所有 resources 共用一致的介面轉換狀態 ■ 一組有限的良好定義操作 well-defined operations RESTful API - REST
  • 5. RESTful API - RESTful ❖REST 的要求: ➢ 使用者端 / 伺服器端 Client/Server ➢ 狀態無關 Stateless ➢ 可以快取 Cacheable ➢ 分層的 Layered ➢ 標準化的介面 Uniform interface ❖符合以上原則 (principles) 的系統稱做 RESTful 。
  • 6. RESTful API - 有什麼優點 ❖支援快取 caching 將改善反應時間跟 server 的負載能力。 ❖因為不必維持連結狀態,大大改善 server 的 scalability 能力。這表示 不同 server 可以處理同一串 requests 。 ❖一個瀏覽器就可以存取任一應用程式跟資源, client 端不需使用別的軟 體。 ❖在 HTTP 之上不依存其他機制跟軟體。 ❖跟其他連結方式相比 ( 如 RPC) ,可以提供相等的功能。 ❖不需要其他的 discovery 機制,因為使用超連結了。
  • 10. JSON Web Token (JWT)
  • 11.
  • 12. JWT 特性 ❖無法真正「登出」 ➢ JWT 裡包含足夠的訊息可用來登入 ➢ 只能將 Client 的 Cookie 刪除 ❖維持連線 alive ➢ 有效時間內可拿舊 Token 換新 Token ➢ 設定長期間的 Token (14 天或 30 天 ) ➢ 自己實作定期換 Token
  • 13. Django REST Framework ❖使用 django REST framework (DRF) 來開發 RESTful APIs ❖DRF 提供三種認證機制 ➢ BasicAuthentication ➢ SessionAuthentication ➢ TokenAuthentication
  • 15. ❖Token 和 User 是一對一關係 ➢ 同一個 Client 在多台機器上登入都會使用同一個 Token ➢ 將 Client 「登出」會將 Token 刪除 ■ 其他機器的 Token 將無法再使用 ❖除非從 Database 裡刪除 Token ,否則永久存在。 DRF Token 特性
  • 16. ❖使用 SSL 連線 ❖使用 SSL 連線 ❖使用 SSL 連線 安全性問題
  • 17. ❖實作 Django 認證系統的 REST 套件 ❖利用 DRF 認證機制的第三方套件 ❖Supported authentication backends ➢ HTTP Basic Auth ( 預設 ) ➢ Token based authentication from Django Rest Framework ❖ 設定 ➢ 帳號是否需要 activate ➢ 密碼是否需要再次輸入 Introduction to Djoser
  • 18. ❖提供的 APIs: ➢ /register/ 註冊 ➢ /login/ 登入 (token based authentication) ➢ /logout/ 登出 (token based authentication) ➢ /password/ 更換密碼 ➢ /password/reset/ 重設密碼 ( 發送 email) ➢ /password/reset/confirm/ 重設密碼 (email 裡的 link) Djoser APIs
  • 19. 認證信功能 ❖要求輸入註冊時的 email 而不是帳號 ❖使用「加密」的 {uid} (base64 encode) 和 {token} (Django token) ➢ /password/reset/confirm/{uid}/{token} ➢ e.g. /password/reset/confirm/MQ/491-55796529106ab9437a42 ❖可修改 email 的 template ❖使用 Django 的 urls 和 view 來產生重設密碼的頁面
  • 20. 我們正在打造的… ❖網通產品解決方案 ❖Web based desktop ➢ 使用 Django 作為 Backend ➢ 透過 RESTful APIs 串接 AngularJS ➢ Single page application (SPA) ❖以套件管理為基礎的作業系統 ❖跨平台的嵌入式系統
  • 21. Single Page Application PythonJavascript DjangoAngularJS $resource ($http) Django REST framework RESTful API (JSON) HTML / CSS Database ORM Front-end Back-end Language Framework Module / App 21
  • 22. Atlas ❖NEXCOM embedded system ❖完整的 Firmware ,包含 bootloader 、 kernel 、 rootfs 、 web GUI 等等。 kernel bootloader kernel bootloader kernel bootloader x86 ARM PowerPC rootfs