عرض عملي: إصدار JWT والتحقق منه
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
issue and validate signed JWTs in Shop. Prepares JNR-038-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Add a
POST /api/auth/loginthat checks credentials and builds a JWT withsub,iss,aud, shortexp. - Sign it with a key read from configuration (not from source code).
- Configure the API as a resource server:
oauth2ResourceServer(o -> o.jwt(...))with aJwtDecoderthat checks issuer and audience. - Call the API with the token and see
200. - Planned mistake: putting the user's email and phone in the claims. Fix: keep only the ID and roles.
- Decode the token on a debugger site and point out the readable payload.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.