-
Notifications
You must be signed in to change notification settings - Fork 71
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
Implement OAuth as its now in Domoticz Beta #679
Comments
Flow and pseudo code (WIP):
Now this Bearer token should be provided with each request between the App and Domoticz using the 'Authorization' header. Once the token has expired (receiving 401 from Domoticz), the refresh token can be used to request a new token without the need to go through the above process and asking the User for credentials again.
|
I could be wrong, but isnt the whole purpose of having a oauth pkce flow to not ask the user for credentials yourself from within the app. I would expect to open a browser with some parameters (challenge etc) to let Domoticz handle the authentication. And then use the access/refresh tokens afterwards Thats how i understand it from for example Okta |
That is indeed how it works on the web. And if you 'sent' the user to Domoticz, it will ask for a User/Pass (currently through standard Basic Auth dialog of the browser and not via a nice login dialog at the moment) and redirect the User back. I am not an App developer, I do not know if/how an App could send the User to their Domoticz instance, perform the login there and then get redirect back to the App. But I know it can be done as I see it work in multiple apps. But you are right, ideally the App does not require to ask for User/Pass and just receives the 'code' and can continue from there. Let's make that work! And I am happy to help where I can. |
Yes, that is correct :) Domoticz internal OAuth2/OIDC service does not have such nice (2-step) login/consent screens yet, but I am working on a (single-step) login/consent screen.. That will be available soon in an upcoming Domoticz Beta. But everything else is already there and can be implemented. Just currently the browser does not show a nice login but the standard Basic Auth dialog. But that is not relevant to complete the App side of the flow. If I can help somehow with testing or ... let me know. |
@galadril , I updated my initial comment with the Flow/Pseudo code... The 'client_id' AND the 'client_secret' are both needed. Although using PKCE ensures the code exchange is not compromised, it does not authenticate the client application (more on this can be found here). And the 'client_secret' has to be provided when doing the POST to the token endpoint. This way the specific app instance gets a trust relation with the specific Domoticz instance. Don't forget to query the |
@kiddigital Did the new Domoticz update bring your oAuth to the stable release?? |
Yes! 😁 Give it a go.. |
I will.. but yeah moving houses, Android Auto support and Wear OS stopped working came in between.. |
@kiddigital while going throught this, i just got the idea.. why shouldn't we have a build-in client id/secret for the mobile app? |
Makes sense indeed.. saves the User a step. |
Can you provide me a build-in id/secret? |
There is no really build-in id/secret, just entries in the Just create an Application called 'DomoticzMobileApp' with a random secret ( A few default entries will be there by default (disabled except the standard UI) including 'DomoticzMobileApp'. But the User has to explicitly activate it AND set a secret (either private or public key-pair). Otherwise any app could fake it is a default app and only need User/Pass. The default apps just make it easier (no typos in ClientID for example). |
was this done already btw? |
Yes, there is an optional field for the 2FA code for Users that have 2FA enabled. And by default there is an 'domoticzMobileApp' application available in the 'Applications' config which is disabled by default and has to be enabled. |
More info about OAuth:
https://github.com/domoticz/domoticz/blob/development/SECURITY_SETUP.md
The text was updated successfully, but these errors were encountered: