fix: authenticate per request #2258

Merged
konrad merged 1 commits from dpschen/frontend:feature/authenticate-per-request into main 2022-09-04 14:30:13 +00:00
Member

It seems to me that the token should be checked on every request.

I'm not sure if this should also be used this way with the the AuthenticatedHTTPFactory.

It seems to me that the token should be checked on every request. I'm not sure if this should also be used this way with the the AuthenticatedHTTPFactory.
dpschen added the
kind/bug
label 2022-08-14 10:10:13 +00:00
konrad was assigned by dpschen 2022-08-14 10:10:13 +00:00
Member

Hi dpschen!

Thank you for creating a PR!

I've deployed the changes of this PR on a preview environment under this URL: https://2258-feature-authenticate-per-request--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.

Have a nice day!

Beep boop, I'm a bot.

Hi dpschen! Thank you for creating a PR! I've deployed the changes of this PR on a preview environment under this URL: https://2258-feature-authenticate-per-request--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/. Have a nice day! > Beep boop, I'm a bot.
dpschen changed title from WIP: fix: authenticate per request to fix: authenticate per request 2022-08-14 15:48:54 +00:00
dpschen requested review from konrad 2022-08-14 15:49:16 +00:00
Owner

There are cases where it would not be checked, like the login and register routes. IIRC these don't use a service, hence it made sense to put the check into AbstractService and not in the common http handler.

There are cases where it would not be checked, like the login and register routes. IIRC these don't use a service, hence it made sense to put the check into `AbstractService` and not in the common http handler.
dpschen force-pushed feature/authenticate-per-request from 3098d9c70e to 24d67b512b 2022-08-18 09:41:21 +00:00 Compare
dpschen force-pushed feature/authenticate-per-request from 24d67b512b to 5b06302c23 2022-08-18 16:20:38 +00:00 Compare
dpschen force-pushed feature/authenticate-per-request from 5b06302c23 to 3b679bf273 2022-08-19 09:14:18 +00:00 Compare
konrad requested changes 2022-09-02 15:04:16 +00:00
@ -66,2 +66,4 @@
// Set the interceptors to process every request
this.http.interceptors.request.use((config) => {
// Set the default auth header if we have a token
const token = getToken()

Isn't this now duplicated with the code in src/http-common/index.ts?

Isn't this now duplicated with the code in `src/http-common/index.ts`?
Author
Member

I guess it could use the AuthenticatedHTTPFactory.
Here I was simply replacing all static token occurances with dynamic ones. It was static in line 91

I guess it could use the AuthenticatedHTTPFactory. Here I was simply replacing all static token occurances with dynamic ones. It was static in line 91

I'm not 100% sure if it would be easy or make sense but I think we shouf put this in a function used in both places.

I'm not 100% sure if it would be easy or make sense but I think we shouf put this in a function used in both places.
Author
Member

What's the difference to using AuthenticatedHTTPFactory directly?

What's the difference to using AuthenticatedHTTPFactory directly?

I think that could work. Can you check?

I think that could work. Can you check?
Author
Member

Done.

Now I also set the apiUrl fresh from window for every request.
By doing so we should never run in the case where an api instance exists but uses an outdated baseUrl (if the user changes it).

Done. Now I also set the `apiUrl` fresh from window for every request. By doing so we should never run in the case where an api instance exists but uses an outdated baseUrl (if the user changes it).
dpschen force-pushed feature/authenticate-per-request from 3b679bf273 to 166ebf18f2 2022-09-04 10:48:16 +00:00 Compare
dpschen requested review from konrad 2022-09-04 10:57:55 +00:00
konrad approved these changes 2022-09-04 14:30:00 +00:00
konrad left a comment
Owner

Awesome, thanks!

Awesome, thanks!
konrad merged commit 6e4a3ff199 into main 2022-09-04 14:30:13 +00:00
konrad deleted branch feature/authenticate-per-request 2022-09-04 14:30:13 +00:00
This repo is archived. You cannot comment on pull requests.
No description provided.