JWT Authentication in Rust [Full Guide : Axum & Actix]

cudidotdev March 11, 2024
Video Thumbnail
cudidotdev Logo

cudidotdev

View Channel

About

Software engineer, Rust programming, Computer science

Video Description

A beginner-friendly tutorial on implementing JWT (Json Web Token) authentication in a Rust web API 00:00 Introduction and scope 00:32 Project setup 04:17 Axum route handlers 11:45 Encode struct to jwt 21:23 Axum Extractor (from request parts traits) 27:41 Decode jwt to struct 30:05 Axum Extractor continued 32:30 Acitx web route handlers 38:42 Actix Extractor (from request trait) 44:25 Securing routes with middleware #rust #axum #jwt #actixweb #actix Rust Axum Actix Web JSON Web Token Github repo: https://github.com/cudidotdev/JWT-Authentication-with-Rust-Axum-and-Actix Axum Response: https://docs.rs/axum/latest/axum/response/type.Response.html JsonWebToken encode function: https://docs.rs/jsonwebtoken/9.2.0/jsonwebtoken/fn.encode.html JsonWebToken crate: https://crates.io/crates/jsonwebtoken JWT validation struct: https://docs.rs/jsonwebtoken/9.2.0/jsonwebtoken/struct.Validation.html Axum custom extractor: https://docs.rs/axum/latest/axum/extract/index.html#defining-custom-extractors Actix web traits: https://docs.rs/actix-web/latest/actix_web/index.html#traits Actix web internal error: https://docs.rs/actix-web/latest/actix_web/error/struct.InternalError.html Axum middleware functions: https://docs.rs/axum/latest/axum/middleware/index.html#functions Actix middleware: https://docs.rs/actix-web/latest/actix_web/middleware/index.html

You May Also Like

Enhance Your Gaming Experience

AI-recommended products based on this video

Loading...
Logitech G435 Lightspeed and Bluetooth Wireless Gaming Headset - Lightweight Over-Ear Headphones, Built-in mics, 18h Battery, Compatible with Dolby Atmos, PC, Mobile - Black

Logitech G435 Lightspeed and Bluetooth Wireless Gaming Headset - Lightweight Over-Ear Headphones, Built-in mics, 18h Battery, Compatible with Dolby Atmos, PC, Mobile - Black

(14,873)
$49.99$39.99
FREE delivery Thu, Aug 21
400+ bought in past month
Loading...
Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black
Best Seller

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

(17,871)
$27.98$22.38
FREE delivery Tue, Oct 14 on your first order
500+ bought in past month
Loading...
Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

Logitech G305 LIGHTSPEED Wireless Gaming Mouse, Hero 12K Sensor, 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery Life, On-Board Memory, PC/Mac - Black

(21,223)
$44.98
FREE delivery Tue, Oct 14
1K+ bought in past month
Loading...
Logitech G502 HERO High Performance Wired Gaming Mouse, HERO 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC / Mac, Black
Best Seller

Logitech G502 HERO High Performance Wired Gaming Mouse, HERO 25K Sensor, 25,600 DPI, RGB, Adjustable Weights, 11 Programmable Buttons, On-Board Memory, PC / Mac, Black

(54,445)
$49.98$44.98
FREE delivery Tue, Oct 14
1K+ bought in past month
Loading...
New SteelSeries Arctis Nova Pro for Xbox Multi-System Gaming Headset - Premium Hi-Fi Drivers - Hi-Res Audio - 360° Spatial - GameDAC Gen 2 - Quad-DAC - ClearCast Gen 2 Mic - Xbox, PC, PS5/PS4, Switch

New SteelSeries Arctis Nova Pro for Xbox Multi-System Gaming Headset - Premium Hi-Fi Drivers - Hi-Res Audio - 360° Spatial - GameDAC Gen 2 - Quad-DAC - ClearCast Gen 2 Mic - Xbox, PC, PS5/PS4, Switch

(517)
$209.41$122.65
PrimeFREE delivery Sat, Jun 14
Loading...
NEW SteelSeries Arctis Nova 3 Multi-Platform Gaming Headset - Signature Arctis Sound - ClearCast Gen 2 Mic - PC, PS5/PS4, Xbox Series X|S, Switch, Mobile

NEW SteelSeries Arctis Nova 3 Multi-Platform Gaming Headset - Signature Arctis Sound - ClearCast Gen 2 Mic - PC, PS5/PS4, Xbox Series X|S, Switch, Mobile

(9,500)
$99.98$67.37
PrimeFREE delivery Sat, Jun 14
100+ bought in past month
Loading...
HyperX Cloud II - Gaming Headset, 7.1 Surround Sound, Memory Foam Ear Pads, Durable Aluminum Frame, Detachable Microphone, Works with PC, PS5, PS4, Xbox Series X|S, Xbox One – Red

HyperX Cloud II - Gaming Headset, 7.1 Surround Sound, Memory Foam Ear Pads, Durable Aluminum Frame, Detachable Microphone, Works with PC, PS5, PS4, Xbox Series X|S, Xbox One – Red

(73,207)
$89.99
FREE delivery Thu, Aug 21
500+ bought in past month
Loading...
CORSAIR MP700 PRO 4TB M.2 PCIe Gen5 x4 NVMe 2.0 SSD – M.2 2280 – Up to 12,400MB/sec Sequential Read – High-Density TLC NAND – Black

CORSAIR MP700 PRO 4TB M.2 PCIe Gen5 x4 NVMe 2.0 SSD – M.2 2280 – Up to 12,400MB/sec Sequential Read – High-Density TLC NAND – Black

(302)
$619.99$566.36
FREE delivery Tue, Jun 17
Loading...
Corsair MP600 PRO LPX 4TB M.2 NVMe PCIe x4 Gen4 SSD - Optimized for PS5 (Up to 7,100MB/sec Sequential Read & 6,800MB/sec Sequential Write Speeds, High-Speed Interface, Compact Form Factor) Black

Corsair MP600 PRO LPX 4TB M.2 NVMe PCIe x4 Gen4 SSD - Optimized for PS5 (Up to 7,100MB/sec Sequential Read & 6,800MB/sec Sequential Write Speeds, High-Speed Interface, Compact Form Factor) Black

(8,521)
$449.99
FREE delivery Tue, Jun 17
Loading...
Turtle Beach Stealth 600 Wireless Multiplatform Amplified Gaming Headset for Xbox Series X|S, Xbox One, PC, PS5, PS4, Nintendo Switch, & Mobile – Bluetooth, 80-Hr Battery, Noise-Cancelling Mic – Black
Best Seller

Turtle Beach Stealth 600 Wireless Multiplatform Amplified Gaming Headset for Xbox Series X|S, Xbox One, PC, PS5, PS4, Nintendo Switch, & Mobile – Bluetooth, 80-Hr Battery, Noise-Cancelling Mic – Black

(3,680)
$99.96
FREE delivery Tue, Oct 14
800+ bought in past month
Loading...
Turtle Beach Stealth Ultra High-Performance Wireless Gaming Controller Licensed for Xbox Series X|S, Xbox One, Windows PC & Android – LED Dashboard, Charge Dock, RGB Lighting, 30-Hr Battery, Bluetooth

Turtle Beach Stealth Ultra High-Performance Wireless Gaming Controller Licensed for Xbox Series X|S, Xbox One, Windows PC & Android – LED Dashboard, Charge Dock, RGB Lighting, 30-Hr Battery, Bluetooth

(1,771)
$224.95$199.41
PrimeFREE delivery Sat, Jun 14
Loading...
Razer BlackShark V2 X Gaming Headset: 50mm Drivers - Cardioid Mic - Memory Foam Cushion - Lightweight- Comfortable, Noise Isolating Earcups - for PC, PS4, PS5, Switch - 3.5mm Audio Jack - Black ECOLOGO

Razer BlackShark V2 X Gaming Headset: 50mm Drivers - Cardioid Mic - Memory Foam Cushion - Lightweight- Comfortable, Noise Isolating Earcups - for PC, PS4, PS5, Switch - 3.5mm Audio Jack - Black ECOLOGO

(16,830)
$47.98$38.38
FREE delivery Sat, Nov 15
1K+ bought in past month
Loading...
Razer Universal Quick Charging Stand for Xbox Series X|S: Magnetic Secure Charging - Matches Forza Horizon 5 Limited Edition Xbox Wireless Controller - USB Powered - (Controller Sold Separately)

Razer Universal Quick Charging Stand for Xbox Series X|S: Magnetic Secure Charging - Matches Forza Horizon 5 Limited Edition Xbox Wireless Controller - USB Powered - (Controller Sold Separately)

(1,103)
$52.27$33.70
PrimeFREE delivery Sat, Jun 14
Loading...
Bose QuietComfort Wireless Noise Cancelling Headphones, Bluetooth Over Ear Headphones with Up to 24 Hours of Battery Life, Moonlight Grey - Limited Edition

Bose QuietComfort Wireless Noise Cancelling Headphones, Bluetooth Over Ear Headphones with Up to 24 Hours of Battery Life, Moonlight Grey - Limited Edition

(12,251)
$269.00
FREE delivery Tue, Oct 14
Loading...
soundcore VR P10 Wireless Gaming Earbuds, Meta Quest 2 Accessories, 30ms Low Latency, Dual Connection, 2.4GHz Wireless, USB-C Dongle Included, Compatible with Steam Deck, PICO 4, PS4, PS5, PC, Switch

soundcore VR P10 Wireless Gaming Earbuds, Meta Quest 2 Accessories, 30ms Low Latency, Dual Connection, 2.4GHz Wireless, USB-C Dongle Included, Compatible with Steam Deck, PICO 4, PS4, PS5, PC, Switch

(2,206)
$69.99
FREE delivery Tue, Jun 17
50+ bought in past month
Loading...
soundcore by Anker P20i True Wireless Earbuds, 10mm Drivers with Big Bass, Bluetooth 5.3, 30H Long Playtime, IPX5 Water-Resistant, 2 Mics for AI Clear Calls, 22 Preset EQs, Customization via App

soundcore by Anker P20i True Wireless Earbuds, 10mm Drivers with Big Bass, Bluetooth 5.3, 30H Long Playtime, IPX5 Water-Resistant, 2 Mics for AI Clear Calls, 22 Preset EQs, Customization via App

(61,759)
$29.99
FREE delivery Sat, Jun 14 on your first order
4K+ bought in past month
Loading...
soundcore P31i by Anker, Real-Time Adaptive Noise Cancelling, Hi-Res Sound, Translation Earbuds, 50H Playtime, Wireless Earbuds, Bluetooth Earphones, Spatial Audio, Fast Charging, IP55 ClimatePartner certified

soundcore P31i by Anker, Real-Time Adaptive Noise Cancelling, Hi-Res Sound, Translation Earbuds, 50H Playtime, Wireless Earbuds, Bluetooth Earphones, Spatial Audio, Fast Charging, IP55 ClimatePartner certified

(105)
$39.99
FREE delivery Thu, Nov 27
Loading...
soundcore by Anker Q20i Hybrid Active Noise Cancelling Headphones, Wireless Over-Ear Bluetooth, 40H Long ANC Playtime, Hi-Res Audio, Big Bass, Customize via an App, Transparency Mode, Ideal for Travel

soundcore by Anker Q20i Hybrid Active Noise Cancelling Headphones, Wireless Over-Ear Bluetooth, 40H Long ANC Playtime, Hi-Res Audio, Big Bass, Customize via an App, Transparency Mode, Ideal for Travel

(39,496)
$52.99
FREE delivery Sun, Oct 19
3K+ bought in past month