You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Nextcloud OAuth2
  2. For this backend, you need to have an OAuth2 enabled Nextcloud Instance, e.g.
  3. on your own private server.
  4. ## Setting up Nextcloud Test Environment
  5. To test, you only need a working Docker image of Nextcloud running on a public
  6. URL, e.g. through [traefik](https://traefik.io/)
  7. ```docker-compose.yml
  8. version: '2'
  9. networks:
  10. traefik-web:
  11. external: true
  12. services:
  13. app:
  14. image: nextcloud
  15. restart: always
  16. networks:
  17. - traefik-web
  18. labels:
  19. - traefik.enable=true
  20. - traefik.frontend.rule=Host:${NEXTCLOUD_DNS}
  21. - traefik.docker.network=traefik-web
  22. environment:
  23. SQLITE_DATABASE: "database.sqlite3"
  24. NEXTCLOUD_ADMIN_USER: admin
  25. NEXTCLOUD_ADMIN_PASSWORD: admin
  26. NEXTCLOUD_TRUSTED_DOMAINS: ${NEXTCLOUD_DNS}
  27. ```
  28. and start it up via
  29. ```
  30. NEXTCLOUD_DNS=goth.my.server.name docker-compose up -d
  31. ```
  32. afterwards, you will have a running Nextcloud instance with credentials
  33. ```
  34. admin / admin
  35. ```
  36. Then add a new OAuth 2.0 Client by going to
  37. ```
  38. Settings -> Security -> OAuth 2.0 client
  39. ```
  40. ![Nextcloud Setup](nextcloud_setup.png)
  41. and add a new client with the name `goth` and redirection uri `http://localhost:3000/auth/nextcloud/callback`. The imporant part here the
  42. two cryptic entries `Client Identifier` and `Secret`, which needs to be
  43. used in your application.
  44. ## Running Login Example
  45. If you want to run the default example in `<goth>/examples`, you have to
  46. retrieve the keys described in the previous section and run the example
  47. as follows:
  48. ```
  49. NEXTCLOUD_URL=https://goth.my.server.name \
  50. NEXTCLOUD_KEY=<your-key> \
  51. NEXTCLOUD_SECRET=<your-secret> \
  52. SESSION_SECRET=1 \
  53. ./examples
  54. ```
  55. Afterwards, you should be able to login via Nextcloud in the examples app.
  56. ## Running the Provider Test
  57. The test has the same arguments as the login example test, but starts the test itself
  58. ```
  59. NEXTCLOUD_URL=https://goth.my.server.name \
  60. NEXTCLOUD_KEY=<your-key> \
  61. NEXTCLOUD_SECRET=<your-secret> \
  62. SESSION_SECRET=1 \
  63. go test -v
  64. ```