# JWT認証 (Node.js / NestJS) > Passport.js、JWT strategy、guards、bcrypt、refresh token、トークンの有効期限 - 25 面接問題 - Mid-Level - [面接問題: Node.js / NestJS](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions.md) ## 1. JWT(JSON Web Token)とは何ですか? **回答** JWTは、当事者間で情報をJSONオブジェクトとして送信するためのコンパクトで安全なフォーマットを定義するオープン標準(RFC 7519)です。完全性を保証するためにデジタル署名され、暗号化することもできます。JWTは必要な情報をすべて含み、サーバー側のセッションを必要としないため、REST APIのステートレス認証で一般的に使用されます。 ## 2. JWTの構造はどうなっていますか? **回答** JWTはドットで区切られた3つの部分で構成されます:Header(署名アルゴリズムとタイプ)、Payload(claims/データ)、Signature(完全性の検証)。各部分はBase64URLでエンコードされます。例:eyJhbGc.eyJzdWI.SflKxwRJ。この構造により、データが改ざんされていないことを保証しながらデータを転送できます。 ## 3. JWTを扱うために使用されるNestJSのパッケージはどれですか? **回答** @nestjs/jwtは、NestJSにおけるJWTトークンの生成と検証を容易にするために、jsonwebtokenパッケージのアブストラクションを提供します。JwtModuleを介してNestJSのモジュールシステムと統合され、sign()、signAsync()、verify()、verifyAsync()などのメソッドを持つJwtServiceを公開します。完全な認証のためには@nestjs/passportと組み合わせる必要があります。 ## さらに22問利用可能 - JwtService.sign()メソッドの役割は何ですか? - JwtService.verify()メソッドの役割は何ですか? 無料で登録: https://sharpskill.dev/ja/login ## その他のNode.js / NestJS面接トピック - [Node.js の基礎](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/nodejs-fundamentals.md): 20問, Junior - [Node.js コア API](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/nodejs-core-apis.md): 25問, Junior - [非同期プログラミング](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/asynchronous-programming.md): 25問, Junior - [Express.js の基礎](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/express-basics.md): 20問, Junior - [NestJSの基礎](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/nestjs-fundamentals.md): 23問, Junior - [REST API 設計](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/rest-api-design.md): 20問, Junior - [バリデーションとDTO](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/validation-dto.md): 20問, Junior - [APIドキュメントと契約](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/api-documentation.md): 20問, Junior - [エラーハンドリング](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/error-handling.md): 20問, Junior - [ユニットテスト](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/testing-unit.md): 20問, Junior - [タスクスケジューリング](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/scheduling-cron.md): 15問, Junior - [NestJS のモジュールと DI](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/nestjs-modules-di.md): 20問, Mid-Level - [設定と環境管理](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/configuration-environment.md): 20問, Mid-Level - [認可とRBAC](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/authorization-rbac.md): 20問, Mid-Level - [TypeORMによるデータベース](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/database-typeorm.md): 30問, Mid-Level - [Prisma ORM](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/prisma-orm.md): 25問, Mid-Level - [ミドルウェアとインターセプター](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/middleware-interceptors.md): 20問, Mid-Level - [ファイルアップロード](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/file-upload.md): 15問, Mid-Level - [WebSockets](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/websockets.md): 20問, Mid-Level - [NestJSによるGraphQL](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/graphql-basics.md): 25問, Mid-Level - [エンドツーエンドテスト](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/testing-e2e.md): 20問, Mid-Level - [Redisによるキャッシング](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/caching-redis.md): 20問, Mid-Level - [Bull によるキュー](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/queues-bull.md): 20問, Mid-Level - [DevOps、Logging、CI/CD](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/logging-monitoring.md): 25問, Mid-Level - [Docker とコンテナ化](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/docker-containerization.md): 25問, Mid-Level - [マイクロサービス](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/microservices.md): 30問, Senior - [セキュリティのベストプラクティス](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/security-best-practices.md): 25問, Senior - [パフォーマンスとクラウドデプロイ](https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/performance-optimization.md): 30問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/node-nestjs/interview-questions/authentication-jwt