Skip to content

Commit

Permalink
Merge pull request #7 from Favo02/authorization
Browse files Browse the repository at this point in the history
Authorization
  • Loading branch information
Favo02 authored Apr 22, 2024
2 parents 34a7213 + 7179985 commit d30e247
Show file tree
Hide file tree
Showing 12 changed files with 368 additions and 77 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SIHL_ENV=production
SIHL_SECRET=<secret>
DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<database>
CORS_ORIGIN=<frontend url>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TL;DR: **Docker** 🐳 + **GitHub Actions** 🤖 for backend and **Cloudflare Pa

## Contributing

Each contribution is **welcome**, especially building alteranive better frontends _(if you are brave enough to write JavaScript code)_ that uses the same API.
Each contribution is **welcome**, especially building alteranive better frontends _(if you are brave enough to write JavaScript code)_.

Please follow the [conventions](#conventions) below.

Expand Down
7 changes: 6 additions & 1 deletion backend/src/common/middlewares.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ let verify_expiration =

let logger = Opium.Middleware.logger

let allow_cors = Opium.Middleware.allow_cors ()
let allow_cors =
let origin = match Sihl.Configuration.read_string "CORS_ORIGIN" with
| Some origin -> origin
| None -> "*" (* this will make the authorization (Set-Cookie headers) NOT work *)
in
Opium.Middleware.allow_cors ~origins: [ origin ] ()
8 changes: 1 addition & 7 deletions frontend/.env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# template for .env file

# production (the default URL is already set)
VITE_API_URL=https://cessadvisorapi.favo02.dev

# development
# VITE_API_URL=http://localhost:3000
VITE_API_URL=<backend url>
19 changes: 19 additions & 0 deletions frontend/src/components/checkAuth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion frontend/src/routes/+error.svelte

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 76 additions & 22 deletions frontend/src/routes/login/+page.svelte

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions frontend/src/routes/logout/+page.svelte

This file was deleted.

104 changes: 100 additions & 4 deletions frontend/src/routes/profile/+page.svelte

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d30e247

Please sign in to comment.