Forum
External auth causes problems with assets (listing)
My Perch resources dir has 50+ files in it, but when I go the Assets in the Perch admin it doesn't show any files. The directory is a symlink, but the diagnostics says it's writable, the browser can load files from it, I can add new files, and the permissions are correct. Any new files that I add (successfully) don't show up in the list, but are stored on the server. I don't believe this because of assets being deleted as adding a new assets results in the same behaviour – on server, but not shown in Perch Assets.
Any ideas?
Perch Runway: 3.1.1, PHP: 7.2.5, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $, with PDO
Server OS: Linux, fpm-fcgi
Installed apps: content (3.1.1), assets (3.1.1), categories (3.1.1), perch_blog (5.5.1), perch_forms (1.11)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_forms', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /chroot/home/--/--/releases/1/html/perch
PERCH_CORE: /chroot/home/--/--/releases/1/html/perch/core
PERCH_RESFILEPATH: /chroot/home/--/--/releases/1/html/perch/resources
Image manipulation: GD
PHP limits: Max upload 50M, Max POST 50M, Memory: 256M, Total max file upload: 50M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home/--/--/html
HTTP_HOST: --
Perch doesn't import assets from the folder. It will only list assets that have been added using the Assets functionality.
Okay...so I've added more than 1 through the asset functionality (either when editing a region or in the asset manager) but they aren't showing when I go back to the list. Right after adding, the image thumbnail shows on the edit (when using the asset manager), but when I got back to the assets list there's nothing there.
How are your filters set?
I'm assuming that if my URL is "/perch/core/apps/assets/" then I'm not (not filter query params). If filters are remembered, then I'm clicking the Assets link on the left and I'm not seeing anything.
I've just checked the DB and the resources table has 49 records in it.
Actually...may have found the issue. Maybe you can direct to where I might find the solution.
Turned on debug and found this query and error:
So, it looks like a problem with my custom auth plugin...but I'm not sure how.
It looks like I need to specify a table name in the auth provider...? But, looking at the
perch3_users
table, there's no columnroleSlug
– did it not get updated during the migration (I think from 3 to 3.1) that I did today?Disable any additional plugins and try Assets again.
Disabling the auth plugin does make the assets work.
So, I copied exactly what's on the Authentication plugins help page but it still doesn't work.
Here's the debug and errors at the bottom of the page:
If I add the following lines within the
PerchAPI_AuthPlugin::recover()
method and this does get it to work:But that's definitely not a solution.
Where you have
YOUR_USER_TABLE
, that should be the name of your user table.How do I set that? The custom auth page doesn't mention this. Also, what will Perch be looking for in that table? Seems weird to me that it'd be querying a table it doesn't manage. (What happens if it's in a different database?)
The table name is specified in your authenticator class.
Changed the error, but not by much (my table name is
user
):It's adding the Perch table name prefix. Even if this does work, my table doesn't have
roleSlug
Full debug output:
Why are you querying the table?
I'm not. As far as I can tell, your code is looking for roleSlug and then running a query (as per Looking up missing property roleSlug in the debug).
I've setup a plain Perch Runway install. Without the auth plugin, the assets work perfectly. Once I add the auth plugin (no other changes), the assets no longer show and the errors show up.
This file is located at
perch/addons/plugins/auth/symfony/auth.php
as per the docs.The file is a near copy of your doc page plus the addition of
protected $table = 'user';
as per.If needed, I can set you a copy the code/database or access to the server if needed (privately of course).
Any updates on this?
Thanks!
I'm not really sure what help you're looking for here. You don't appear to have implemented any login functionality at all.
Hi Drew,
I'm not even sure where to start. Let try to explain this.
I am doing actual authentication. I am only providing a simple example to show where the issue is. As I've said, I've copied what's on your documentation page to accomplish this.
Your documentation for providing your external authentication is incomplete (https://docs.grabaperch.com/api/auth/) as per requiring the addition of
protected $table = 'user';
in the auth class (as per previous messages in this conversation).I am not querying your user table – your code is. In my real code, I'm querying my own table and you should not be querying my table (though you are telling me the opposite).
Your code is querying the "user" table looking for roleSlug – I don't care, nor do I or my code know anything about roleSlugs. According to the docs, you only say I need to return the "role" which I am.
Can you please try following your instructions on setting up external authentication with the example you provide in the docs (https://docs.grabaperch.com/api/auth/) in an empty Runway site? This is all I've done and I'm receiving this error.
I've put my code on github: https://github.com/xmmedia/perch_auth_bug The auth file as above, is here: https://github.com/xmmedia/perch_auth_bug/blob/master/perch/addons/plugins/auth/external/auth.php
Again, that's not my real auth file – I'm only using this to reproduce the issue and show that there are no other plugins/etc.
Looking forward to resolving this. Thanks Darryl
Hi Drew,
Any thoughts on where the issue lies?
No, but I'll take a look at it when I get a chance to set this all up. Obviously this is a fairly involved thing you're asking me to look at, so it's not something I can answer quickly.
Hi Drew,
Are there any updates on this? I can send you a copy of the exact code I'm using for you to try along with the DB so it only takes a quick setup to try it. I don't want to have to learn all of the Perch auth and asset code to figure out what's going on.