Automagically connect Thundermail Calendar in FTUE#1544
Conversation
577d577 to
f08d7ae
Compare
c547a88 to
42d316f
Compare
MelissaAutumn
left a comment
There was a problem hiding this comment.
Still need to test, but I don't see why this wouldn't work. Thanks!
Needs some code de-duping though 😄
| sentry_sdk.set_extra('debug_object', debug_obj) | ||
| raise UnexpectedBehaviourWarning(message='Cache incorrect', info=debug_obj) | ||
| except UnexpectedBehaviourWarning as ex: | ||
| sentry_sdk.capture_exception(ex) |
There was a problem hiding this comment.
Since this is entirely thunderbird accounts we probably don't need the debug object information. This was just to capture information about failing caldav servers (and I think we've caught all those edge-cases too.)
There was a problem hiding this comment.
Hmmm fair but since I've extracted this into a shared _resolve_caldav_url for both cases, perhaps it wouldn't hurt to leave it?
|
@MelissaAutumn sorry for the ping on the re-review but when you have some time, could take another look on this PR? 🙏 |
MelissaAutumn
left a comment
There was a problem hiding this comment.
I haven't tested it, but the code looks fine!
|
|
||
| oauth2_scheme = OAuth2PasswordBearer(tokenUrl='token', auto_error=False) | ||
|
|
||
| async def get_bearer_token(request: Request) -> str | None: |
There was a problem hiding this comment.
Oh thanks, but this was okay to punt to another ticket 😅
| ) | ||
|
|
||
| return RedirectResponse(f'{os.getenv("FRONTEND_URL", "http://localhost:8080")}/post-login/{one_time_access_token}') | ||
| return RedirectResponse(f'{os.getenv("FRONTEND_URL", "http://localhost:8090")}/post-login/{one_time_access_token}') |
There was a problem hiding this comment.
In a future ticket we should move these to a constant value.
| OIDC_TOKEN_INTROSPECTION_URL= | ||
| OIDC_FALLBACK_MATCH_BY_EMAIL= | ||
|
|
||
| # Required for Appointment's CalDAV auto-setup, needs to match the one in thunderbird-accounts |
There was a problem hiding this comment.
I recommend leaving this blank in the example env.
| TB_ACCOUNTS_CALLBACK=http://localhost:5000/accounts/callback | ||
| TB_ACCOUNTS_CLIENT_ID | ||
| TB_ACCOUNTS_SECRET | ||
| TB_ACCOUNTS_CALDAV_URL=http://host.docker.internal:8081 |
There was a problem hiding this comment.
Important to note this won't work for all docker setups.
| case 'oidc': | ||
| await ftueStore.moveToStep(FtueStep.ConnectCalendarsThundermail); | ||
| case 'oidc': { | ||
| isLoading.value = true; |
There was a problem hiding this comment.
You know I don't know if this actually works within the same function call. I know we do it in other places but I don't think I've tested this.
It might work since the await might trigger a dom update eventually, but might be worth a test with a really long delay.
There was a problem hiding this comment.
You are spot on, it does seem to work because of the await triggering a dom update and Vue batching updates. Tested here with a long delay and it updates the buttons accordingly!
Description of the Change
docker-compose.ymlcontainer ports not to clash withthunderbird-accountswhen running locallyTB_ACCOUNTS_CALDAV_URLenv var.POST '/caldav/oidc/auth'route to attempt to connect to the CalDAV through the OIDC token.ConnectYourCalendarThundermailStepas we don't need it anymore + related i18n and enum entries.Here's the flow:
POSTrequest to/caldav/oidc/authPOSTrequest to Account's Backend/appointment/caldav/setup/passing theAPPOINTMENT_CALDAV_SECRETand the current logged in user's OIDC tokenWarning
Requires thunderbird/thunderbird-accounts#616 to be merged in first for the best experience on testing this
How to test it
Alright, first of all, this is a joint effort with the
thunderbird-accountsrepo so make sure you are in the branchappointment-auto-setup-caldav(thunderbird/thunderbird-accounts#469) and you are able to run adocker compose upin boththunderbird-accountsand this branch inAppointment.Make sure you have the .env var
APPOINTMENT_CALDAV_SECRETset in boththunderbird-accountsand this branch to the same values.Accounts Prerequisites
http://localhost:8087/adminand login with useradmin@example.organd passwordadmin.http://localhost:8087/admin/subscription/plan/add/. None of the information here actually matter except for the Product which has to be an active product.http://localhost:8087/and you should be redirected to the/subscribepage.PS: This whole step is required because only then we will have the
authenticate.Usermodel created + the actual Stalwart account to create the App Password.Steps to test, now in Appointment-land
http://localhost:8090, if you are redirected to Keycloak, login with the sameadmin@example.org/adminas before.Thundermail CalendarBooking Pagestep with the Stalwart Calendar pre-selected. All that without manually creating an App Password!Benefits
Applicable Issues
Fixes #1352