In this chapter, we are going to explore Representational State Transfer (REST) API authentication patterns. These patterns are session-based authentication, JSON Web Tokens (JWT), and Open Authentication 2 (OAuth 2.0). We will try to leverage the Gorilla package's sessions library to create basic sessions. Then, we will move on to advanced REST API authentication strategies, such as stateless JWT. Finally, we will discuss the OAuth 2.0 authentication pattern and the security aspects of an API. In the previous chapter, the Amazon Web Services (AWS) API Gateway took care of authentication (using Identity and Access Management (IAM) roles) for us. If an API Gateway is not present, how do we secure our API? You will find the answer in this chapter.
In this chapter, we will cover the following topics:
- How simple authentication works...