Skip to Main Content
Building Serverless Python Web Services with Zappa
book

Building Serverless Python Web Services with Zappa

by Abdulwahid Abdulhaque Barguzar
July 2018
Intermediate to advanced content levelIntermediate to advanced
324 pages
8h 14m
English
Packt Publishing
Content preview from Building Serverless Python Web Services with Zappa

Implementing authentication

Authentication is an essential feature to secure the REST API from unauthorized access. So, in order to implement the authentication layer, we are going to use the JWT mechanism. Here, we are going to design two REST APIs for registering a user and for login access.

To persist the data related to users, we would need to define a user model. The following is the code snippet of the User model.

File—auth/models.py:

import refrom datetime import datetimefrom app.config.models import BaseModelfrom sqlalchemy.orm import synonymfrom werkzeug.security import generate_password_hash, check_password_hashfrom app import dbclass User(BaseModel, db.Model):    __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Docker for Microservices with Python

Hands-On Docker for Microservices with Python

Jaime Buelta

Publisher Resources

ISBN: 9781788837613Supplemental Content