Home > Back-end >  Sharing Wordpress login with Laravel Application
Sharing Wordpress login with Laravel Application

Time:04-15

I have a WordPress website where people log in and access information. This information has links to documents; these documents need to be self-hosted. Some companies block access to Dropbox and Box, and some users sometimes get confused with the google drive viewer application.

I tried using a doc viewer plugin for WordPress, which would mean creating a post/page for each document. The ideal scenario would be to open each document in the viewer as google drive does.

I was able to find a Laravel application that allows me to host the documents on my own server and create sharable links; the only problem is that users need to be logged in to the Laravel application to access all the documents features.

I want to use authentication cookies in the Laravel application from WordPress, so users don't have to log in to Laravel. Has anyone done something like this?

I have heard of SAML or using a WP_Lgoin hook, or even define( 'COOKIE_DOMAIN', 'www.example.com' ); in wp-config.

CodePudding user response:

You can not do that without authentication or you can use a source manager to share right file without authentication

CodePudding user response:

If it's on the same domain, you should be able to hook into the WP session to know if they logged in from WP. You could also set your own session value from WP at login to grab know who they are and if they are auth. There are tons of ways to do this.

Me personally I'd set encrypted session variables that I could process on a middleware route file. That way I'd know who they are, if they're auth, and where to send them back to after viewing the doc.

Seems like a lot of work though just to view a doc though. You can just provide as a download. They can still grab the file it just won't be editable in the browser. Unless I'm missing something here. It's been awhile since I've done anything wordpress but I also think you can auth directories by role. So to gain access to the Stuff directory you have to be in the Stuff group.

  • Related