Code Explainers
Code explainers tagged #authentication
typescript
import { inject } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivateFn,
How a functional route guard works in Angular
route-guards
dependency-injection
rxjs
Intermediate
5 steps
javascript
const express = require('express'); const session = require('express-session'); const RedisStore = require('connect-redis').default; const { createClient } = require('redis');
Redis-backed session auth in Express
sessions
authentication
redis
Intermediate
8 steps
rust
use axum::{ async_trait, extract::{FromRequestParts, State}, http::{header, request::Parts, StatusCode},
Custom auth extractors in Axum
extractors
authentication
error-handling
Intermediate
9 steps
typescript
import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpHandler,
Refreshing tokens with an Angular HttpInterceptor
http-interceptor
token-refresh
rxjs
Advanced
8 steps
python
import os from datetime import datetime, timezone import jwt
JWT bearer auth as a FastAPI dependency
authentication
jwt
dependency-injection
Intermediate
7 steps
go
package middleware import ( "crypto/subtle"
Building an API-key middleware in Gin
middleware
authentication
dependency-injection
Intermediate
5 steps
go
package api func RegisterRoutes(r *gin.Engine, deps *Dependencies) { r.GET("/health", func(c *gin.Context) {
Layering route groups and middleware in Gin
routing
middleware
authentication
Intermediate
8 steps
php
<?php namespace App\Services;
Building signed, expiring download URLs in PHP in Laravel
hmac
url-signing
authentication
Intermediate
7 steps
go
package middleware import ( "bytes"
Verifying webhook HMAC signatures in Gin
hmac
middleware
webhooks
Intermediate
7 steps
typescript
import { createParamDecorator, ExecutionContext, UnauthorizedException,
Building a @CurrentUser decorator in NestJS
decorators
authentication
request-context
Intermediate
6 steps
rust
use axum::{ body::Bytes, extract::State, http::{HeaderMap, StatusCode},
Verifying Stripe webhook signatures in Axum
hmac
webhooks
constant-time-comparison
Intermediate
8 steps
php
<?php namespace App\Http\Controllers\Auth;
Rate-limited login in Laravel
authentication
rate-limiting
validation
Intermediate
9 steps
rust
use axum::{ body::Body, extract::Request, http::{header, StatusCode},
How bearer-auth middleware works in Axum
middleware
authentication
request extensions
Intermediate
7 steps
go
package auth import ( "net/http"
Building a JWT auth middleware in Gin
middleware
jwt
authentication
Intermediate
7 steps
rust
use axum::{ extract::FromRef, http::StatusCode, response::{IntoResponse, Redirect},
Signed cookie sessions in Axum
sessions
cookies
authentication
Intermediate
8 steps
python
import time from dataclasses import dataclass, field from fastapi import Depends, FastAPI, HTTPException, Request, status
Token-bucket rate limiting in FastAPI
rate-limiting
token-bucket
dependency-injection
Advanced
10 steps
javascript
import { cookies } from 'next/headers'; import { NextResponse } from 'next/server'; import { SignJWT, jwtVerify } from 'jose';
JWT session cookies in a Next.js Route Handler
authentication
jwt
cookies
Intermediate
8 steps
java
@Component public class JwtAuthenticationFilter extends OncePerRequestFilter { private final JwtTokenProvider tokenProvider;
How a JWT auth filter works in Spring
authentication
jwt
servlet-filter
Intermediate
8 steps