Skip to content
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

Multi Auth system in laravel #153

Open
koushikSen opened this issue Sep 11, 2018 · 7 comments
Open

Multi Auth system in laravel #153

koushikSen opened this issue Sep 11, 2018 · 7 comments

Comments

@koushikSen
Copy link

I am doing a project where multi-auth is necessary. Does this package support laravel multi-auth? even though I set up project environment as multi auth suggests, DynamDB package always getting the content of user model.

@baopham
Copy link
Owner

baopham commented Sep 12, 2018

Sorry, could you give more clarification on your use case? What was the setup (Laravel and DynamoDB)? What is the expectation of using this library? What do you want to achieve?

@koushikSen
Copy link
Author

Hi @baopham, sorry for the late reply.
It is in laravel 5.4 and with dynamodb 0.5.0, I wanted to use the "Users" table for user panel login and separate "Admins" table for managing. I wanted to use DynamoDBUsers model for Users and a custom DynamoDBAdmin model for Admins and both will use Auth or login validation. Now even if I set Auth:: guard('admin') it is searching Users table for that particular login credential.

is it clear from the above definition what I am trying to achieve?

@baopham
Copy link
Owner

baopham commented Sep 22, 2018

This library doesn't work with Laravel auth out of the box. Usually when you want "users", you would want "roles" too and that involves setting up relationship like many-to-many and DynamoDB doesn't play well with that.

But seems like there is a need for it as you're not the first person asking about auth. Please refer to #157 for progress (if I happen to get enough time to work on it).

@zoul0813
Copy link
Contributor

If using DynamoDB, I’d recommend Cognito as an auth backend.

My app does client side auth, and passes an auth token cookie to the server - whenever I need to check if the user is logged in, that token goes through my custom Cognito auth middleware which verifies the jwtToken. IF my backend needs access to the User record itself, then I pull it out of Cognito/DynamoDB depending on what I’m doing (Cognito syncs profile data with Dynamo, but not the other way around).

It results in very few reads from Dynamo, and does not require my backend to cache the user either... as I usually don’t need to know anything other than “are they logged in” or “are they a member of X group”.

Vue is used to render any user specific data on the front end - such as username in the user dropdown of the menu, etc.

@foo123
Copy link

foo123 commented Oct 13, 2019

I am also interetsed in multi-auth integration. @zoul0813 can you explain a little more about your cognito middleware in laravel? Are you using this package https://github.com/black-bits/laravel-cognito-auth?

@zoul0813
Copy link
Contributor

@foo123, no. I use the cognito client side JavaScript to authenticate and simply pass the auth token that Cognito generates as a cookie.

The middleware was custom written, and just decided the jwt auth token and verified it. If it was valid, then the user was authenticated.

I had it setup to sync Cognito user data with a lambda function, which wrote the data to dynamodb.

My profile edit was also client side, and would write data to Cognito... which would then trigger the lambda sync.

Unfortunately, I can’t provide any code or examples as I’m not longer working on that project and do not have access to it.

@foo123
Copy link

foo123 commented Oct 13, 2019

@zoul0813 that is fair enough explanation. Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants