README.adoc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. = Spring Data AOT Sample
  2. To compile this project, you will need to use a special Java compiler.
  3. If you are using SDKMan!, then the version will be correctly selected for you.
  4. Or, you can do the following:
  5. ```bash
  6. sdk use java 23.0.5.r17-nik
  7. ```
  8. After that, you can compile like so:
  9. ```bash
  10. ./gradlew nativeCompile
  11. ```
  12. Once compiled, you can run like so:
  13. ```bash
  14. ./build/native/nativeCompile/data
  15. ```
  16. Then you can query for messages using `luke/password` and `rob/password`.
  17. Because the domain objects are secured, you will see a subset of fields with `luke`.
  18. For example, querying `/` with `luke`, you'll see:
  19. ```json
  20. ...
  21. {
  22. "created": "2014-07-12T16:00:00Z",
  23. "id": 112,
  24. "summary": "Is this secure?",
  25. "text": "This message is for Luke",
  26. "to": {
  27. "email": "luke@example.com",
  28. "id": "luke",
  29. "password": "password"
  30. }
  31. }
  32. ...
  33. ```
  34. However, with `rob`, you'll also see `firstName` and `lastName` like so:
  35. ```json
  36. ...
  37. {
  38. "created": "2014-07-12T04:00:00Z",
  39. "id": 102,
  40. "summary": "Is this secure?",
  41. "text": "This message is for Rob",
  42. "to": {
  43. "email": "rob@example.com",
  44. "firstName": "Rob",
  45. "id": "rob",
  46. "lastName": "Winch",
  47. "password": "password"
  48. }
  49. }
  50. ...
  51. ```
  52. You can also change the message text.
  53. To do this, copy and paste the `X-CSRF-TOKEN` and `Cookie: JSESSION` headers and include them in a `PUT :8080/102` request.
  54. An example of this request using HTTPie can be seen below:
  55. ```bash
  56. echo -n "updated message" | http -a rob:password PUT :8080/102 "X-CSRF-TOKEN: {copied from GET request}" "Cookie: JSESSIONID={copied from GET request}"
  57. ```
  58. Read more about the https://docs.spring.io/spring-security/reference/servlet/authorization/method-security.html#authorize-object[`@AuthorizeReturnObject`] and https://docs.spring.io/spring-security/reference/servlet/authorization/method-security.html#fallback-values-authorization-denied[]`@DeniedHandler`] in the Spring Security Reference.