-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Support for vue / quasar applications #47
Comments
Hello @Excel1, Thanks for the interest and sorry about the lack of documentation. To give you some highlights:
Regarding the code your provided: Based on what I see, most of this code could easily be removed as it is already managed by this library. Regarding Apple's guidelines: This library will never use the "system browser" as it is not considered a best practice. Regarding offline mode: The library will automatically renew the user's tokens, one minute prior to access_token expiration (this could be overridden by settings). At that time, it will uses the refresh_token to do the renewal. Regarding tokens storage: On desktop On mobile
Regarding your questions:
Anything that was working with oidc-client-ts should work with this library
Have a look at: #30 (comment)
Migration should be fairly easy as the idea behind this library is to do everything for you |
@Badisi At first thank you for the detailed answer. I tried to translate oidc-client.ts code into using your code. Can you take a look if the transformation should working? Preparations
Code Transformationauth.service.ts
to
Questions
authentication.ts - bootQuestions
auth.store.tsQuestions
How can i do get the user? routerGuard.ts - boot
Questions
Vue LibI am very grateful for your help! If I get it working and understand your library better, I will try to convert it into a Vuelib in a study project. |
@Excel1, thanks for the follow-up. Hard for me to tell based only on those code snippets...
The idea of this library is to start before anything else (i.e. to start even before the bootstrap of your app).
Not sure you really needs to do it with my lib. But for info you can override anything that's
You don't have to do anything at all. Just call
It's actually only available in the Angular implementation. But I have plan to port it to the VanillaJS one. In your case you would have to keep your current Vue implementation. If you can provide a sample project as I said, I would be able to provide a Vue interceptor.
Like I said before, the lib should be initialized even before your app. So in case your IDP is not reachable, your app won't load at all and you can simply present to the user a fallback page with a login button so he can retry the authentication (I can also provide this scenario in the sample project).
Depends on your needs
Already answered it :-) |
Yes ofc. https://github.com/Excel1/quasar-authjs I have created a simple Quasar Project with a protected and unprotected page (HomePage). Additionally I added a RouterGuard and the auth.service.ts to abstract this, if it makes sense. I changed a few things and tried to map the login process according to suspicion. I have tried to follow most of the instructions and orientated myself on the projects, but so far I have not been able to log in because initOidc does not seem to be a function. I hope you can recognise the approach and you can do something with it :) If you would like to explain it, so that I can understand it and possibly write documentation - that would be super helpful! As already mentioned, the boot files are executed at the beginning (boot/routerGuard). If you need more information or the code is not enough for you, contact me and I will try to adapt the code |
Was not an easy one, but this was due to the fact that quasar was not supporting esm yet. |
@Excel1, I've already managed to make a working version of your project with login and logout. |
@Badisi Thank you for the fast help! - I added you as a contributor and will update my main project to the release candidate and try to take over the implementation from the project. You are welcome to copy the entire quasar-authjs and put it into your demo folder if you like! |
Thanks, I have pushed a pre-version of my modifications. |
@Badisi 🔝 - feel free to contact me, when you are ready :) |
@Excel1, only the interceptor remains now (will do it in the upcoming days). Will write a full detailed explanation of what I did, once it will be finished. |
@Excel1, everything is ready 🥳 I left a few examples in the init of the lib and the routes so you can see what optons are available to you. PS: I didn't tried it on mobile because I don't know how I'm supposed to use Capacitor in Quasar. So if you manage to have Capacitor in the project I could also have a look to see if it works properly. Thanks |
@Badisi Thank you very much. I try to implement it now in a production app. This will take a while (it will take a long while) cause it seems like i got many errors due the change to "@quasar/app-vite": "^2.0.0-rc.3" with causes many import problems... e.g. import { useAuthStore } from 'stores/auth.store'; --> import { useAuthStore } from '../stores/auth.store'; (for each import) I also got my first question: Do i need "vite-plugin-static-copy": "^2.2.0" cause this causes dependency issues. with cue i18n and many more vite plugins.
|
Also i mentioned that you make some configuration changes like in
Are these steps necessary? |
What I have done in the demo projectTemporary modifications
Library usage
|
If migrating to Quasar v2 is too much effort for you right now (even if it will be required one day), I've pushed a branch What was required:
|
Thank you for the work. I tried to implement it into my production project. My changes:
i copied the @auth-vue folder into my /src. Is this still here correct? I have now tried to add vite-plugin-static-copy and got dependency problems.
My Questions:
|
By installing with "--legacy-peer-deps" it was possible to make it work. But eslint throw the next error: By ignoring the folder "/src/@auth-vue"
|
Never use Regarding the error, all the info are in the npm log:
Looking at https://github.com/intlify/vite-plugin-vue-i18n you can easily see that this package is deprecated. |
I got very good news! Its working (but still i have to fine tuning). One problem i found was: With https it works fine. I try out to check how to fine tune and will comment my questions (like always) :) Currently i still didnt check mobile but i hope i can finish up this week. But thanks again for the support so far |
First QuestionWhen |
The new i18n version is unfortunately not compatible with Quasar V1. Since static copy requires a higher Vite version, which is only available via v2, I tried to upgrade the project. Unfortunately, there are serious bugs in v2, which was released yesterday, e.g. i18n is no longer recognised in the project and/or capacitor imports are no longer recognised. Therefore I have to wait until the bugs are fixed in Quasar which will take a few weeks. I will get back to you as soon as I know more! |
After some trials i got it working by using workarounds (recommended by the quasar developers). WebpageIf i refresh the secured page i got logged off/ redirected as told. AndroidYay! The capacitor browser opens - i see the log in page but didnt got redirected back to app. I stuck into the redirection process. Do i have to redirect on special url endings? |
@Badisi i also tried it for quasar version 1 (cause some bugs are still in v2) and it works. This is the current error on refreshing the page.
|
@Excel1. sorry for the long wait. What's your current status ? Do you still need help ?
On mobile (both iOS and Android) you have to specify the
This isn't an error per se, more of a warning to tell you that the user's session couldn't be retrieved. When using
|
Introduction
Currently, there is very little documentation available on using or migrating to badisi auth-js, which makes it challenging to customize my code. For this reason, I am seeking help here. If the implementation is successful, I plan to extend the existing documentation to make the library more accessible.
Current Setup
My project is built with Quasar and Vue 3. I have developed a hybrid application powered by Capacitor, using Keycloak in combination with oidc-client.ts for authentication. While everything works as expected, Apple’s App Store Guideline 4.0 requires using the Safari In-App Browser (via the Capacitor Browser Plugin) for redirection handling instead of the default browser.
Project Details
localhost#/
, while Android useslocalhost/#/
due to a Quasar-specific behavior.Migration Goal
The aim is to adapt the authentication flow to comply with Apple's requirements by switching to badisi auth-js while maintaining the existing functionality and platform-specific quirks.
Current Code Base
auth.service.ts
authentication.ts - boot
auth.store.ts
routerGuard.ts - boot
Questions
The text was updated successfully, but these errors were encountered: