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

How can I implement auth in Laravel for firebase #16

Closed
prajwalpoojari9876 opened this issue Feb 4, 2020 · 4 comments
Closed

How can I implement auth in Laravel for firebase #16

prajwalpoojari9876 opened this issue Feb 4, 2020 · 4 comments

Comments

@prajwalpoojari9876
Copy link

prajwalpoojari9876 commented Feb 4, 2020

I can check valid user by verify password

$user = app('firebase.auth')->verifyPassword($email,$password);
            if($user->emailVerified) {
                    echo 'login success';
             }

Now further query

$docRef = app('firebase.firestore')->database()->collection('MyCollectionName')
                    ->where('name', '==', 'anyname')
                    ->documents();

But how the above query is authenticated to user logged in.

@jeromegamez
Copy link
Member

That's currently not possible with the SDK - it's on my todo list but will require some serious rewrites, so there's, unfortunately, no ETA.

@prajwalpoojari9876
Copy link
Author

ok. So as of now, can we go this way
As soon as the verify password sends true. We store the uid in the laravel session and all further queries will be made through uid.

I know it would not be safe. But all queries would be through Laravel.

And other related query is that what createCustomToken, verifyIdToken does?. This are for server validation if we go RESTful apis.

@jeromegamez
Copy link
Member

You can store the UID in the session, but connections from your PHP application to the Firebase Servers will still be authenticated with your service account credentials (= Admin Access).

verifyIdToken() is used to ensure that a user token in a request from a Firebase Client Application is valid and not expired. https://firebase.google.com/docs/auth/admin/verify-id-tokens

createCustomToken() is used to create a custom token with additional claims to send back to a Firebase Client Application. https://firebase.google.com/docs/auth/admin/create-custom-tokens

@prajwalpoojari9876
Copy link
Author

Thanks @jeromegamez

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

No branches or pull requests

2 participants