Top Banner
Authentication of RESTful API on Django Cobalt [email protected]
16

Auth of restful_api

Jan 22, 2018

Download

Technology

Tun-Yu Chang
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Auth of restful_api

Authentication of RESTful API on Django

[email protected]

Page 2: Auth of restful_api

About me

● Cobalt Chang

● From Application Software, Network & Communication Solutions BG, Nexcom International Co., Ltd.

● Software RD of an industry computer company?

– Production testing?

Page 3: Auth of restful_api

What we do?

● AngularJS + Django

● Version control, Test spec

● Gitlab, Continuous Integration(CI)

● Docker

● Kanban, Lean startup in the enterprise

● LinkedIn

– https://www.linkedin.com/in/tun-yu-chang-7965279a

Page 4: Auth of restful_api

Outline

● Introdustion to RESTful API

● Packages for building API

– Django REST Framework

– Djoser● Packages for documenting API

– Django REST Swagger

– Sphinx (not in this talking)● Demo

● Appendix

Page 5: Auth of restful_api

●RESTful API - REST

● REST, Representational State Transfer

– Resource● Uniform Resource Identifier (URI)

– Representation● html, xml, json, etc.

– State Transfer● well-defined operations

Page 6: Auth of restful_api

●RESTful API - RESTful

● The formal REST constraints are

– Client–server

– Stateless

– Cacheable

– Layered system

– Uniform interface● It's RESTful

Page 7: Auth of restful_api

●RESTful API - APIs

● For example, RESTful Web APIs

– base URI, such as http://example.com/resources/

– often JSON resources, but can be others

– standard HTTP methods

– hypertext links to reference state

Resource GET PUT POST DELETE

Collection URI, such as http://api.example.com/resources/

List Replace Create Delete

Element URI, such as http://api.example.com/resources/item17

Retrieve Replace / Create

Create Delete

https://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services

Page 8: Auth of restful_api

●Django REST Framework

● Django REST framework is a powerful and flexible toolkit for building Web APIs

● http://www.django-rest-framework.org/

Page 9: Auth of restful_api

●Djoser

● REST implementation of Django authentication system

● https://github.com/sunscrapers/djoser

Page 10: Auth of restful_api

● pip install djoser

● Configure INSTALLED_APPS

● Configure urls.py

Page 11: Auth of restful_api

● Authentication

– HTTP basic authentication

– Token based authentication● Features

– Register a new user

– Activate the user

– Send email to set new password

Page 12: Auth of restful_api

●Django REST Swagger

● An API documentation generator for Swagger UI and Django REST Framework

● https://github.com/marcgibbons/django-rest-swagger

Page 13: Auth of restful_api

● pip install django-rest-swagger

● Configure INSTALLED_APPS

● Configure urls.py

Page 15: Auth of restful_api

Appendix

● Similar projects on DRF

– django-rest-auth

https://github.com/Tivix/django-rest-auth

– django-rest-framework-jwt

https://github.com/GetBlimp/django-rest-framework-jwt

– ...

Page 16: Auth of restful_api

Appendix

● Other API Creations

– Django-tastypie

– Piston

– ...● https://www.djangopackages.com/grids/g/api/