Skip to content

Ajsalemo/SpringBootAuthenticationExamples

Repository files navigation

SpringBootAuthenticationExamples

Different examples of Spring Boot REST API's secured with Auth0 connecting to various databases


All samples are REST API's secured by Auth0. The only accessible path on these API's are the root path '/' and '/swagger-ui/. A Authorization header with your 'Bearer xxx...' token as a value from Auth0 must be passed into the protected routes, or else a HTTP 401 occurs. Reference this link for more information. These samples can be ran locally or deployed, both containerized and non containerized. Seed data is included under the database directory in the projects. These were created and used with Maven in mind. Run mvn clean package and mvn spring-boot:run in the directory of the pom.xml to start.


Swagger

All examples have Swagger v3.0.0 implemented. The UI can be accessed from the '/swagger-ui/' path. For example, localhost:8080/swagger-ui/.


MongoDB Example

The MongoDB example under the springbootauth0mongodb directory is a Spring Boot project which has the option to connect to a locally running MongoDB instance as well as a connection URI example to connect to Mongo Atlas.

Routes

  • '/' - Home route
  • '/find_all_inventory' - A GET request. Get all inventory within the collection specified
  • '/inventory/{id}' - A GET request. Finds an item by ID. Pass in the ID of a specific item to retrieve it's information.
  • '/add_inventory' - A POST request. Accepts a JSON object with proper fields to add an item to the collection.
  • '/delete_inventory/{id}' - A DELETE request. Accepts the ID passed into the URL of a known item to delete from the collection.
  • '/update_inventory/{id}' - A PUT request. Accepts the ID passed into the URL of a known item to update the item.


MySQL Example

The MySQL example under the springbootauth0mysql directory is a Spring Boot project which has the option to connect to a locally running MySQL instance as well as a connection URI example to connect to Azure Database for MySQL.

Routes

  • '/' - Home route
  • '/get_todo' - A GET request. Get all todos.
  • '/todo/{id}' - A GET request. Find a todo by ID passed into the URL
  • '/add_todo' - A POST request. Accepts a JSON object with the proper fields to add an new todo.
  • '/delete_todo/{id}' - A DELETE request. Accepts the ID passed into the URL of a known todo.
  • '/update_todo/{id}' - A PUT request. Accepts the ID passed into the URL of a known todo to update the todo.


PostgreSQL Example

The PostgreSQL example under the springbootauth0postgres directory is a Spring Boot project which has the option to connect to a locally running MySQL instance as well as a connection URI example to connect to Azure Database for MySQL.

Routes

  • '/' - Home route
  • '/all_listings' - A GET request. Get all AirBNB listings.
  • '/find_by_id/{id}' - A GET request. Find a AirBNB listing by ID passed into the URL.
  • '/add_listing' - A POST request. Accepts a JSON object with the proper fields to add an new AirBNB listing.
  • '/update_listing/{id}' - A PUT request. Accepts the ID passed into the URL of a known AirBNB listing to update the listing.
  • '/delete_listing/{id}' - A DELETE request. Accepts the ID passed into the URL of a known AirBNB listing to delete the listing.

About

Different examples of Spring Boot REST API's secured with Auth0 connecting to various databases

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published