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.
All examples have Swagger v3.0.0 implemented. The UI can be accessed from the '/swagger-ui/' path. For example, localhost:8080/swagger-ui/.
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.
- '/' - Home route
- '/find_all_inventory' - A
GETrequest. Get all inventory within the collection specified - '/inventory/{id}' - A
GETrequest. Finds an item by ID. Pass in the ID of a specific item to retrieve it's information. - '/add_inventory' - A
POSTrequest. Accepts a JSON object with proper fields to add an item to the collection. - '/delete_inventory/{id}' - A
DELETErequest. Accepts the ID passed into the URL of a known item to delete from the collection. - '/update_inventory/{id}' - A
PUTrequest. Accepts the ID passed into the URL of a known item to update the item.
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.
- '/' - Home route
- '/get_todo' - A
GETrequest. Get all todos. - '/todo/{id}' - A
GETrequest. Find a todo by ID passed into the URL - '/add_todo' - A
POSTrequest. Accepts a JSON object with the proper fields to add an new todo. - '/delete_todo/{id}' - A
DELETErequest. Accepts the ID passed into the URL of a known todo. - '/update_todo/{id}' - A
PUTrequest. Accepts the ID passed into the URL of a known todo to update the todo.
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.
- '/' - Home route
- '/all_listings' - A
GETrequest. Get all AirBNB listings. - '/find_by_id/{id}' - A
GETrequest. Find a AirBNB listing by ID passed into the URL. - '/add_listing' - A
POSTrequest. Accepts a JSON object with the proper fields to add an new AirBNB listing. - '/update_listing/{id}' - A
PUTrequest. Accepts the ID passed into the URL of a known AirBNB listing to update the listing. - '/delete_listing/{id}' - A
DELETErequest. Accepts the ID passed into the URL of a known AirBNB listing to delete the listing.