< 282022-09-29⋎30 >

Topic for #farmOS is: farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Forum: farmOS.discourse.groupSet by mstenta on 2021-06-15 at 12:52
02:00*polo has joined
02:09*polo has quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
09:00*RafatKhashan[m] has quit (Quit: You have been kicked for being idle)
12:17mstenta[m]@room farmOS 2.0.0-beta7 has been released! 🎉 github.com/farmOS/farmOS/releases/tag/2.
13:38*waves again - sunset here - good morning!
13:39evered[m]*sunrise
13:39* * waves again - sunrise here - good morning!
15:10mstenta[m]@room Weekly dev call in about 50 minutes: meet.jit.si/farmos-dev - All are welcome!
15:20mstenta[m]paul121: I wonder if we could try to test the simple_oauth 5.2 stuff again
15:20mstenta[m]I have it all set up locally (along with PHP8) so we can dive in if we want
15:22evered[m]testing is good - "trust but verify"
15:31mstenta[m]paul121: I'd also love to talk about `composer.lock` if we have some time :-)
15:53paul121[m]Both sound good
15:54paul121[m]I'm having post "upgraded my os" woes...
15:56paul121[m]Brave/chromium wont load some sites, and won't let me clear browsing data! Arg
15:56symbioquine[m]Time for Firefox!
15:56mstenta[m]womp womp
15:56mstenta[m]i'm gonna jump into the dev call early... nothing else to do 😄
17:02paul121[m]symbioquine: re: github.com/farmOS/farmOS-map/issues/184
17:02paul121[m]I wanted to ask your opinion about the "convenience" method. It might be able to add a convenience method before a larger refactor of using the interaction "active" state?
17:03paul121[m]Adding the convenience method would introduce the abstraction to however things are implemented, allowing the implementation to change
17:04paul121[m]But I still need to evaluate how important this even is for the use case I was working on, not sure yet
20:17mstenta[m]paul121: I am idly starting to run the oauth tests to see if I can get a sense of what's happening
20:21FarmerEd[m]Oath client is not included in this code by any chance is it?
20:22mstenta[m]Nothing has changed in 2.0.0-beta7
20:23mstenta[m]We're working on upgrading the oauth module ahead of php8 support
20:31FarmerEd[m]I know that,
20:31FarmerEd[m]But I possibly need to include an oath client for some modules to authenticate with other software.
20:31FarmerEd[m]But then again could probably get away with just using the http client already included with Drupal.
20:34FarmerEd[m]I suppose the opposite of what you are working on.
20:35mstenta[m]Oooh you mean like what we were talking about with the USDA making a module for the USDA eAuth identity provider?
20:35mstenta[m](Similar to something like "login with your google account")
20:38FarmerEd[m]No not that either,
20:38FarmerEd[m]I have some node red flows for synchronizing the Department of Agricultures herd database with farmOS but considering migrating to a module. So I'd need my farmOS instance to be the client which connects to the other server via Oauth2
20:38mstenta[m]Oooh ok gotcha :-)
20:38mstenta[m]Yea you're kinda on your own with that. There isn't anything in farmOS that helps with that specifically.
20:39mstenta[m]But I know paul121 has done some things with similar integrations using OAuth so he might have some pointers
20:39FarmerEd[m]👍
20:40FarmerEd[m]Cool, I know more or less how it works, just making sure there wasn't anything included before reinventing the wheel
20:42mstenta[m]I mean... maybe there is something included that I'm not aware of! 😄
20:42FarmerEd[m]Think there are a few Drupal client specific modules about too.
20:42mstenta[m]Guzzle at the very least (that's the PHP requests library basically... comparable to Python `requests` or JS `axios` as I understand it)
20:43mstenta[m]But there may be OAuth2 specific libraries on top of that that handle flows
20:43mstenta[m]I'm sure there are... just not sure if it's included in the farmOS code/dependencies
20:44FarmerEd[m]Yea, I've used Guzzle for a few modules already, and built the oauth2 flow I need in node red using http request nodes so can coble something together I'm sure one way or another.
20:45mstenta[m]oauth.net/code/php/
20:45mstenta[m]I imagine this one is what you'd want: github.com/thephpleague/oauth2-client
20:45mstenta[m]Our oauth2 server module uses the opposite package from the same authors
20:45mstenta[m](`oauth2-server` instead of `oauth2-client`)
20:46mstenta[m]> @paul121: I am idly starting to run the oauth tests to see if I can get a sense of what's happening
20:46mstenta[m]OK so... this response has a `401` status code (which I think we expected - just my first clue): github.com/farmOS/farmOS/blob/2.x/module
20:48mstenta[m]So that method return `NULL`... which means `$token_info['id']` is not set here: github.com/farmOS/farmOS/blob/8a2dd9474b
20:48mstenta[m]And that leads to the error we're seeing in the test results (`Undefined array key "id"`)
20:48mstenta[m]Now... we just need to figure out why the response is resulting in `401`! 😄
20:52paul121[m]<mstenta[m]> "But I know paul121 has done some..." <- yep, I've built one OAuth integration but it's just a custom wrapper around the Guzzle client. I wanted to use an oauth-client PHP library but unfortunately their OAuth implementation wasn't 100% to sepc. I've found this is unfortunate & common reality :-/
20:53paul121[m]mstenta[m]: yeah, I think at one point we were able to identify we were not getting a token at all
20:53paul121[m]which could mean many different things :-/
20:55mstenta[m]Gonna try stepping into the post request... even though I have no idea what I'm looking at haha
20:56mstenta[m](and will undoubtedly lead me through a labyrinth of methods...)
20:58FarmerEd[m]Is that module on git by any chance paul121: ?
21:02paul121[m]FarmerEd[m]: yes this farm_farmlab module (the one I wanted to demo!): github.com/paul121/farm_farmlab
21:02paul121[m]This uses the OAuth authorization flow. The client is here, has a couple OAuth helper functions, notably a helper to auto-refresh OAuth tokens which might be useful: github.com/paul121/farm_farmlab/blob/1.x
21:03mstenta[m]Oh that's neat paul121 - I like that it just extends `GuzzleClient`
21:05paul121[m]Another thing I have learned when creating these "client" classes/services is to create a "ClientFactory" service that injects the credentials/api token/etc separate from your actual client class. The drupal/symfony services have native support for this "factory":
21:05paul121[m]- github.com/paul121/farm_farmlab/blob/1.x
21:05paul121[m]- github.com/paul121/farm_farmlab/blob/1.x
21:08FarmerEd[m]Cool paul121: that might just be enough to get me started.
21:09mstenta[m]paul121: ah hmm... maybe a clue: `invalid_client`
21:11mstenta[m]Or maybe that's not helpful haha - it's interesting that that is the message we were seeing in the original test failures (www.drupal.org/project/farm/issues/32821)
21:22paul121[m]ah, that last message is irrelevant. I believe it is fixed with one of our last patches that got included with 5.2.x
21:23mstenta[m]> paul121: ah hmm... maybe a clue: `invalid_client`
21:23mstenta[m]this is what i got tracing through the debugger just now
21:23mstenta[m]will have a better idea shortly... waiting for the functional test to run again and my debugger to stop it :-)
21:23mstenta[m]brute force debugging
21:26mstenta[m]happened here: github.com/thephpleague/oauth2-server/bl
21:26mstenta[m]gonna figure out why next...
21:31mstenta[m]ok...
21:33mstenta[m]I'm in this method: git.drupalcode.org/project/simple_oauth/
21:33mstenta[m]... and it is returning `FALSE`
21:37mstenta[m]It's making it into the last check at the bottom (not sure if it should or not), but `$client_secret` is `null`, so it's returning `FALSE` before it can check `$this->passwordChecker->check($client_secret, $client_drupal_entity->get('secret')->value)`
21:40mstenta[m]I feel like maybe it shouldn't be getting that far?
21:41paul121[m]mstenta[m]: ah. so the consumer has a secret configured, but no `$client_secret` was provided, so it doesn't need to do a password check
21:41mstenta[m]ok...
21:43mstenta[m]so... trying to understand: which block of code do we want to be returning `TRUE` in this test?
21:43mstenta[m]that last block? or the one before it (which it skips over)
21:44mstenta[m](line 71 or line 80?) git.drupalcode.org/project/simple_oauth/
21:44paul121[m]I think those blocks align with the two cases:
21:44paul121[m]First block = the client does not have a `client_secret`
21:44paul121[m]Second block = the client does have a `client_secret`
21:44mstenta[m]ok that makes sense
21:45paul121[m]so it depends if in the test the client has a secret configured
21:45mstenta[m]looking...
21:46mstenta[m]ok so yea... we don't use `client_secret` in any of our tests (if i'm reading correctly)
21:47mstenta[m]oh wait...
21:47paul121[m]but do we inherit the client from their tests?
21:47mstenta[m]ah we doo! yes!
21:47mstenta[m]yes yes yes
21:47mstenta[m]got it
21:48mstenta[m]ah so maybe they started using `client_secret` in the upstream tests... and we need to update ours to send it... (just a guess... looking....)
21:49mstenta[m]that might be it... running another test...
21:58mstenta[m]to be continued... dinner time :-)
23:58mstenta[m]paul121: Alright! Got that test to pass! Now to see if it fixes the others too... 🤞

< 282022-09-29⋏30 >