forked from goldbergyoni/nodebestpractices
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Basque translation: 6.11 subsection translation
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Onartu JWT zerrenda beltza | ||
|
||
### Azalpena | ||
|
||
Diseinuz, JWTak (JSON Web Tokens) guztiz aberri gabeak (stateless) dira; beraz, igorle batek baliozko token bat sinatzen duenean, token hori benetakoa dela egiaztatu ahal izango du aplikazioak. Horrek dakarren segurtasun arazoa da ihes egindako (leaked) tokena oraindik erabilgarria izango litzatekeela eta ezin daitekeela baliogabetu, sinadurak baliozkoa izaten jarraitzen duelako arazoak eragindako sinadura aplikazioak espero duenarekin bat datorren bitartean. | ||
Hori dela eta, JWT autentifikazioa erabiltzean, iraungitako edo baliogabetutako tokenen zerrenda beltza kudeatu beharko luke aplikazioak, tokenen bat baliogabetu behar den kasuetan, erabiltzailearen segurtasuna bermatzeko. | ||
|
||
### `express-jwt-blacklist` adibidea | ||
|
||
Node.js proiektu batean Express-jwt zerrenda beltza (`express-jwt-blacklist`) egikaritzeko adibidea `express-jwt` erabiliz. Kontuan izan garrantzitsua ez dela express-jwt-zerrenda beltzaren biltegirako ezarpen lehenetsiak (memorian) erabiltzea, baizik eta Redis bezalako kanpoko biltegiren bat erabiltzea Node.js prozesu askotan tokenak baliogabetzeko. | ||
|
||
```javascript | ||
const jwt = require('express-jwt'); | ||
const blacklist = require('express-jwt-blacklist'); | ||
|
||
blacklist.configure({ | ||
tokenId: 'jti', | ||
strict: true, | ||
store: { | ||
type: 'memcached', | ||
host: '127.0.0.1', | ||
port: 11211, | ||
keyPrefix: 'nirewebaplikazioa:', | ||
options: { | ||
timeout: 1000 | ||
} | ||
} | ||
}); | ||
|
||
app.use(jwt({ | ||
secret: 'nire-sekretua', | ||
isRevoked: blacklist.isRevoked | ||
})); | ||
|
||
app.get('/logout', (req, res) => { | ||
blacklist.revoke(req.user) | ||
res.sendStatus(200); | ||
}); | ||
``` | ||
|
||
### Beste blogari batzuek diotena | ||
|
||
[Marc Busqué](http://waiting-for-dev.github.io/blog/2017/01/25/jwt_secure_usage/)ren bloga: | ||
> ...gehitu baliogabetze geruza bat JWTri, izaera apatrida galtzea suposatzen badu ere. |