Тёмный

Login form in React JS with Laravel as the backend for auth passport for access token | SPA - 2 

Amitav Roy
Подписаться 19 тыс.
Просмотров 34 тыс.
50% 1

Опубликовано:

 

9 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@avthreek
@avthreek 4 года назад
Ok, the beginning was terrible, I just made installation by myself. Dont assume that people have same editor with auto class insertion and if you show all the code straight from the docs, we assume that you show all the lines that need to be run, but turns out that you skip some of them, so we still had to go to the docs. If we end up using docs as you did, then why we need the video part? :) In addition to that what is "pa" command? Its not found in my env. I dropped the video straight after this last drop :/ Tip for the next time either ask people to have installed specific libraries by themselves and begin straight away with other stuff, or show ALL the lines.
@amitavroydev
@amitavroydev 10 месяцев назад
will keep in mind
@relaxationmusix3306
@relaxationmusix3306 9 месяцев назад
Please tell me how can we customize expiry time for access tokens from this process ?? Please help me, im stuck in this issue for a long time.
@amitavroydev
@amitavroydev 9 месяцев назад
Now with Laravel sanctum. You can use that which is a better option as of today It's a long lived token
@nutandevjoshi
@nutandevjoshi 4 года назад
I get error >> TypeScript error in /var/www/react/react-spa-laravel-typescript/client/src/pages/homepage/index.tsx(10,10): Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & Pick'. TS2559 8 | return ( 9 | > 10 | | ^ 11 | 12 | 13 |
@amitavroydev
@amitavroydev 10 месяцев назад
.
@aniket-in
@aniket-in 2 года назад
Thanks for the video, I had a query: now as we built the endpoint to get access tokens, the problem is the users can use tools like postman to make api calls directly without using our frontend. Suppose we are building an eCommerce and on flash-sales users are directly using our APIs to place an order, instead of going through the whole checkout flow.
@amitavroydev
@amitavroydev 2 года назад
Well, even if APIs are used there are checks and balances which will stop the user from exploiting. First, while registering I am assuming you will have an email validation policy. So, even if user registration is done through API, the verification cannot be automated. Yes, after login in to the system, the user can automate a few steps. But, the payment verification will happen through webhook. And there is API rate limiting in place to ensure no user is misusing the APIs. And if you are running an Ecom site, ideally you will have some basic firewall in place which will save you from ddos attacks. And automation can be done to non-api sites as well. For example, people have used laravel's dusk to automate form filling and stuff. There, you interact with actual page where card token is generated because dusk opens up chrome browser.
@aniket-in
@aniket-in 2 года назад
@@amitavroydev Thank you so much for the detailed response. I think now I understand what to do, atleast I'll allow CORS using config/cors.php only for my frontend domain, so that modern browsers will block those request if user on other domain. And also I can have some kind of human verification OTP/Captcha etc.. on few endpoints.
@amitavroydev
@amitavroydev 2 года назад
@@aniket-in Hi Aniket glad to be of help. Yes, CORS will help to a certain level if API calls are made from Javascript. However, note that if the calls are made using POSTMAN or something like Guzzle for PHP, then CORS won't be able to help you :) So you see, security is a big thing in itself and there are no clear simple solutions to any security concern. There are always some precautions that we can take. Yes, on important API endpoints, captcha is good specially on form submits because they most probably will result in some inserts. And, you don't want your database to suddenly start inserting 1000s of requests. If you have any more questions, feel free to get in touch. Cheers.
@JorgeMorgado259
@JorgeMorgado259 4 года назад
Hi, thanks for the video. Can you explain how to validate the token before it expires and make refresh token?
@sajsaj
@sajsaj 3 года назад
Another option will be to use a user api which is default and validate the current api token vs existing api. If it's not validated you can create a new or log out the user. This way we used in mobile apps.
@amitavroydev
@amitavroydev 3 года назад
Laravel will validate the token when an API call is made. So, to do a separate call is unnecessary and also not very optimal. The idea is that the user might be able to see the ui of a page if a token has expired because the JavaScript part of the application will load assuming that the token is present (and it won't validate the authenticity of the toke). But the moment you hit any API to get any kind of data from the server, because the Authorization token will be validated, it is going to validate, detect and accordingly the front end can logout the user But yes, this is with the assumption that looking at ui doesn't have any logical impact. But, if the requirement is that ui should not be visible, then validate the token on page load and keep that as a state variable or context variable.
@naazimkhan9953
@naazimkhan9953 4 года назад
Hello sir how I can implement role and permission based login using frontend react and API in laravel??? Can u please help me out of this?
@amitavroydev
@amitavroydev 4 года назад
Well Nazim, there is not much change in the authentication mechanism even of you have roles and permissions. The basic thing is, when the user logs in, you will need the API to send the role and permissions information along with the token so that if there are certain menus links or components that are role based, can be handled. The main thing is, having the API set up with that information. And typically I would use spatie permission to do that in the API. Last but not the least, whenever you have role and permissions in front end and backend, always validate the action's permission for the current user at the server and don't rely on the client. The client can take information to do certain things at the front end. However, for any action double check at the backend
@naazimkhan9953
@naazimkhan9953 4 года назад
@@amitavroydev thank you sir one more thing what about api route protection like don't have permission to edit but have view permission?
@satishksharma
@satishksharma 2 года назад
How to prevent XSS & CSRF attacks with react and laravel
@amitavroydev
@amitavroydev 2 года назад
For csrf, you will have to generate a token on the server side. Will need to check the best implementation. And CSS?
@satishksharma
@satishksharma 2 года назад
@@amitavroydev Typing mistake: not CSS I mean XSS Attack
@amitavroydev
@amitavroydev 2 года назад
Got it... Nextjs has quite a few things to help in this. Might want to check this if you have not done this already nextjs.org/docs/advanced-features/security-headers
@niloflora4316
@niloflora4316 3 года назад
Target class [AccessToken] does not exist.
@niloflora4316
@niloflora4316 3 года назад
Target class [AccessTokenController] does not exist.
@amitavroydev
@amitavroydev Год назад
Solved?
@yoseledwinaguirrebalbin6703
@yoseledwinaguirrebalbin6703 4 года назад
Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & Pick
@amitavroydev
@amitavroydev 11 месяцев назад
that's interesting
@ek3857
@ek3857 4 года назад
Is this Laravel7?
@amitavroydev
@amitavroydev 4 года назад
Yes, the Laravel version is 7.*. However, so far I have not done anything which is specific to Laravel 7. Everything will run even on Laravel 6 or even on 5 I think.
@morykhodarahmi6781
@morykhodarahmi6781 4 года назад
You didn't explain many parts of it and started from the middle
@amitavroydev
@amitavroydev 4 года назад
Yes, the idea was to start with the code base as starting point. I have done a lot of component structuring and all which I felt doesn't warrant a tutorial.
@NishaKumari-lh4is
@NishaKumari-lh4is 4 года назад
Can you provide me code sir.
@amitavroydev
@amitavroydev 4 года назад
This is the repo: github.com/amitavroy/react-spa-laravel-typescript
@ogulcankarayel5625
@ogulcankarayel5625 4 года назад
Please can you share the code
@amitavroydev
@amitavroydev 4 года назад
Why not. the link is added in the description now.
@ogulcankarayel5625
@ogulcankarayel5625 4 года назад
@@amitavroydev thx. How can I control the tokens when user open the app after a while ?
@amitavroydev
@amitavroydev 4 года назад
You can store the token in local store or cookies and read from there
@ogulcankarayel5625
@ogulcankarayel5625 4 года назад
@@amitavroydev stackoverflow.com/questions/63453634/access-and-refresh-token-control-in-react. Please can you review the question that i've posted
@ogulcankarayel5625
@ogulcankarayel5625 4 года назад
@@amitavroydev please help me
Далее
ДОМИК ДЛЯ БЕРЕМЕННОЙ БЕЛКИ#cat
00:45
Reflection 70b Faked?! What We Know So Far...
19:39
Просмотров 57 тыс.
Protected Routes in React using React Router
15:40
Просмотров 345 тыс.
When RESTful architecture isn't enough...
21:02
Просмотров 275 тыс.
Securing a Laravel API in 20 minutes with JWTs
20:36
Просмотров 78 тыс.