169 похожих чатов

Question about authentication by #JWT: 1- My client get loggin and

I generate a token for him/her and store the token in localstorage. No If somebody else copy this token from locanstorage of this person browser and paset in his/her (I mean hacker) browser local storage, this hacker will be logged in? If yes soe is that safe?

2- I put user Id in the token that I generated On login function. On each reuest that is sending to backend I shuld check the JWT token. I should decode token and find userId in it. Now I should I compar this user id by anything? Example checking that is there any session by this user ID in backend or even checking the user Id by DB?

3- should I put an expirattion time for jwt token on local store?

3 ответов

7 просмотров

1. A program's security model can not encompass every possible scenario. To copy jwt tokens from created by some website, You'll need, 1. Physical Access to device or 2. exploit some sort of vulnerability on the website that'll allow arbitrary js script execution. If someone gets physical access to a device then most security models fail so there is nothing you can do about it. Https will prevent second scenario from happening.

2. You can embed user ID in jwt token. When the handler recieves request, You can try decrypting the jwt token. If the decryption succeeds, You know the token was generated with your credentials and is legit otherwise you can return a 400 response.

yes that's your preference but I suggest setting an expiration date of 7-15 days.

Похожие вопросы

Обсуждают сегодня

Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
А чем вам питонисты не угодили?😂
.
79
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
Такой вопросец - есть функция function MySuperDuperConcat(const a: array of AnsiString): AnsiString; Как мне в её теле сделать вот так? Result:=Concat(a); А не грустный вариан...
notme
15
Всем привет. Поделитесь, пожалуйста, опытом. Есть форма, на которой имеется dbgrid и кнопки: добавить, редактировать, удалить. Если нет записей в dbgrid, то кнопки редактирова...
Евгений
5
type TExtensions<GExtender>=class function GetExtension<GEntityExtenderType>:GEntityExtenderType; end; function TExtensions<GExtender>.GetExtension<GEntityExtenderType...
zamtmn
8
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
86
Всем привет, препод задал вопрос, подскажите пожалуйста, какой адрес инкапсулирует указатель?
Свинка Пеппа
8
Почему никто ещё не написал квантовую виртуальную машину на Windows?
КТ315
7
Вот смотрите у меня есть два стрима сейчас fs, cs: TStream; fs := TFileStream.Create('filename'); cs := TCompressionStream.Create(compression_level, fs); Я хочу сделать так: ...
notme
5
Карта сайта