Book Image

Python Network Programming

By : Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
Book Image

Python Network Programming

By: Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker

Overview of this book

This Learning Path highlights major aspects of Python network programming such as writing simple networking clients, creating and deploying SDN and NFV systems, and extending your network with Mininet. You’ll also learn how to automate legacy and the latest network devices. As you progress through the chapters, you’ll use Python for DevOps and open source tools to test, secure, and analyze your network. Toward the end, you'll develop client-side applications, such as web API clients, email clients, SSH, and FTP, using socket programming. By the end of this Learning Path, you will have learned how to analyze a network's security vulnerabilities using advanced network packet capture and analysis techniques. This Learning Path includes content from the following Packt products: • Practical Network Automation by Abhishek Ratan • Mastering Python Networking by Eric Chou • Python Network Programming Cookbook, Second Edition by Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
Table of Contents (30 chapters)
Title Page
Copyright
About Packt
Contributors
Preface
Index

Authenticating REST APIs with Eve


Eve is a REST API server built in Python. We will test how to use Eve REST API framework with BasicAuth, global authentication. Eve can also be started without any authentication at all, as a simple REST API server. This recipe is a simple demonstration of serving the entire web server. However, Eve provides more sophisticated and more role-based access control that protects certain APIs with roles for the users.

The server is started with a username and password, and the client passes on the base64 encode of the format username:password to the server to get authenticated.

Getting ready

First install Eve using Python:

$ sudo pip install eve

This will install Eve, along with its dependencies, cerberus-0.9.2, eve-0.7.4, events-0.2.2, flask-0.12, flask-pymongo-0.5.1, pymongo-3.4.0, simplejson-3.11.1, werkzeug-0.11.15.

In this recipe, we will start a simple server with a username and password as the basic authentication.

How to do it...

First make sure that you have...