{"id":20791524,"url":"https://github.com/jcavat/akka-http-mongodb-cors","last_synced_at":"2026-05-05T13:31:59.575Z","repository":{"id":146385538,"uuid":"174366255","full_name":"jcavat/akka-http-mongodb-cors","owner":"jcavat","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-06T19:59:37.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T10:45:25.407Z","etag":null,"topics":["akka-http","bearer-authentication","cors-request","docker","docker-compose","mongodb","oauth2","scala","snippet","template"],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcavat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-07T15:02:31.000Z","updated_at":"2021-11-11T08:05:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"a827ce2c-6660-409a-9451-8eaafb5f2e53","html_url":"https://github.com/jcavat/akka-http-mongodb-cors","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcavat%2Fakka-http-mongodb-cors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcavat%2Fakka-http-mongodb-cors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcavat%2Fakka-http-mongodb-cors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcavat%2Fakka-http-mongodb-cors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcavat","download_url":"https://codeload.github.com/jcavat/akka-http-mongodb-cors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243136235,"owners_count":20241988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akka-http","bearer-authentication","cors-request","docker","docker-compose","mongodb","oauth2","scala","snippet","template"],"created_at":"2024-11-17T15:45:13.771Z","updated_at":"2025-10-30T13:41:03.037Z","avatar_url":"https://github.com/jcavat.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Akka-http snippet with OAuth2 Bearer + CORS + MongoDB\n\n## Summary\n\nThis snippet is based on [https://github.com/jcavat/akka-http-with-bearer-tokens](https://github.com/jcavat/akka-http-with-bearer-tokens)\n\nWe use OAuth2 baerer to authenticate + CORS + MongoDB database to persist data\n\nThe list of credentials are given in the `application.conf` file in `src/main/resources` folder. MongoDB credentials \nmust be those declared in `docker-compose.yml` file.\n\nThe documents to get/post/persist are defined as case classes : \n\n```\nfinal case class User(_id: Option[ObjectId], name: String, email: String, tags: List[Tag])\nfinal case class Tag(name: String)\n```\n\nRun mongodb with docker-compose:\n\n```\ndocker-compose up -d\n```\n\nCreate `db-users` database and `users` collection with mongo-express at [http://localhost:8081](http://localhost:8081)\n\nRun the server with `sbt run` and try:\n\npost some users :\n\n```\ncurl -H \"Content-Type: application/json\" -H \"Authorization: Bearer ABCD\" http://localhost:8080/users -X POST -d '{\"name\": \"asdf\", \"email\": \"adsf@test.com\", \"tags\": [{\"name\": \"youpie\"}, {\"name\": \"haha\"}]}'\ncurl -H \"Content-Type: application/json\" -H \"Authorization: Bearer ABCD\" http://localhost:8080/users -X POST -d '{\"name\": \"tutu\", \"email\": \"tutu@tutu.com\", \"tags\": []}'\n```\n\nget all users:\n\n```\ncurl -H \"Content-Type: application/json\" -H \"Authorization: Bearer ABCD\" http://localhost:8080/users\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcavat%2Fakka-http-mongodb-cors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcavat%2Fakka-http-mongodb-cors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcavat%2Fakka-http-mongodb-cors/lists"}