Coder Social home page Coder Social logo

todolistapi's Introduction

TodolistAPI

This is a RESTful Web API for creating tasks and organizing them into checklists.

Application.properties

When the application is first started and no application.properties are specified, a template with the most important properties is generated and the placeholders have to be replaced with the real values.

Authentication

spring.security.oauth2.resourceserver.jwt.issuer-uri
spring.security.oauth2.resourceserver.jwt.jwk-set-uri
oauth2.audience

These values are needed to register the authorization-server used for authentication. The issuer uri has to match with the "iss"-claim of the JWT. The jwk-set-uri is where the app gets the info to validate the signature of your JWT. It should be something along the lines of "*/.well-known/jwks.json". The oauth2.audience needs to be the same as the aud-claim in the JWT.

Datasource

spring.datasource.url
spring.datasource.username
spring.datasource.password

To save all the users and tasks and all of that data, you need to specify a database. This spring boot application uses MySQL for persistance. You will have to specify the url of your mysql server as well as the username and password of the MySQL-User this application should use. I recommend creating a separate user for this application with the minimum rights needed for the application. The application only needs access to its own database and has to be able to create own tables and create, read, update and delete records in those tables.

The driver-class-name needed is already specified and should not be changed.

I am not sure if there is a way to add your own driver-classes to an already built spring-boot-application. Right now, you would have to add the dependency for another DBMS to the pom.xml yourself and rebuild the application. Then you could specify the needed driver-class-name in the application.properties file. If you know any other way to setup a different DBMS, please create an issue or make a pull request with the updated README.md, thank you!

Colourful terminal

spring.output.ansi.enabled

The template sets up the terminal to output text with colourful highlights. If you don't want that, you can just remove this property

Running the application

One way to run the application is to just use the command

java -jar todolistAPI-1.0.0.jar

To run the docker container, you can run the following command

docker run -dp {your-port}:8080 ascendise/todolistAPI

You will have to specify the values from application.properties as environment variables. Specify the following values either directly in the command or by specifying the values in a .env-file

spring.security.oauth2.resourceserver.jwt.issuer-uri={your-issuer-uri}
spring.security.oauth2.resourceserver.jwt.jwkt-set-uri={your-jwkt-set-uri}
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url={your-mysql-url}
spring.datasource.username={your-mysql-username}
spring.datasource.password={your-mysql-password}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.output.ansi.enabled=DETECT #Optional

Cross-Origin Resource Sharing (CORS)

By default, the API allows any origin. You can specify only specific origins by setting the following property in application.properties

allowedOriginPatterns=https://example.com,https://example2.com

Make sure to not have any spaces behind commas. You can also use wildcards in the properties.

API-Documentation

The documentation for the API is a Swagger-page located at {your-url}/swagger-ui/index.html

Authentication

The API uses OAuth2 with JWTs to authenticate the user. The aud-claim needs to be equal to the specified spring property oauth2.audience or else authorization fails with a 401 Unauthorized.

Troubleshooting

If you encounter any bugs or steps from this documentation don't work, then feel free to create an issue.

todolistapi's People

Contributors

ascendise avatar semantic-release-bot avatar dependabot[bot] avatar

todolistapi's Issues

Cannot update 'done'-property

Describe the bug
The isDone-Property of the task cannot be updated. It always remains false.

To Reproduce
Steps to reproduce the behavior:

  1. Send PUT to change isDone of task from false to true
  2. See response without updated 'isDone'

Expected behavior
'isDone' should change to provided value

Additional context
Error is in task service. The 'isDone'-property is not updated there

DELETE on resource returns Internal Server Error

Describe the bug
When I send a DELETE request, the API returns with 500 and the resource does not get deleted. I tried it on the /tasks - and the /checklists resource.

To Reproduce
Steps to reproduce the behavior:

  1. Send a DELETE request for an existing entity on /tasks
  2. See error

Expected behavior
DELETE request should return 204 and delete the specified entity

Additional context
Here is the relevant part of the logs:
log-snippet.txt

Logout not working

Describe the bug
I cannot logout via {baseUrl}/logout. Instead of invalidating my session, it just shows an error page. My session is still valid after.

To Reproduce
Steps to reproduce the behavior:

  1. Login via {baseUrl}/login/{ssoProvider}
  2. Logout after via {baseUrl}/logout
  3. See error

Expected behavior
/logout should invalidate my session. It should not show any errors. I shouldn't be able to access any resources after.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.4
  • Browser Firefox
  • Version 101.0.1

Additional context
I just suspect some misconfiguration in SecurityConfigurations but still have to investigate on that.

500 when accessing root as anonymous user

Describe the bug
Cannot access the root as an anonymous user to retrieve all the available links

To Reproduce
Steps to reproduce the behavior:

  1. Go to '{url}/'
  2. See error

Expected behavior
For an anonymous user it should just show the link for logging in e.g. {url}/login

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Firefox
  • Version 101.0.1

Additional context
The 500 Server Error gets returned because the service tries to get the user (via the @currentuser annotation). But because there is no user logged in in the current session, it throws an error.

user-Link not sent in root-Endpoint

Describe the bug
The link for the /user-Endpoint is missing from the response of the root-Endpoint

To Reproduce
Steps to reproduce the behavior:

  1. Send GET-Request to '/'
  2. Try to find the /user-link
  3. Cry

Expected behavior
The link to the /user-Endpoint should also be sent by the root-Endpoint

Some errors return a Whitelabel Error Page, instead of just an error code

Describe the bug
When triggering an error, sometimes the API returns a default error web page.

To Reproduce
Steps to reproduce the behavior:

  1. Go to {baseUrl}/unknownPage
  2. See error

Expected behavior
The api should not return a web page. It should just return the error code.

Screenshots
image

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.4 LTS x86_64
  • Browser Firefox
  • Version 101.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.