Code Explainers

Code explainers tagged #authorization

php
<?php
 
namespace App\Http\Controllers;
 

Time-limited signed download links in Laravel

signed urls authorization file streaming
Intermediate 6 steps
php
<?php
 
namespace App\Http\Requests;
 

Normalizing input in a Laravel FormRequest

validation authorization input-normalization
Intermediate 6 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
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\ReportController;

How nested route groups compose in Laravel

routing middleware authorization
Intermediate 8 steps
ruby
class ArticlesController < ApplicationController
  before_action :set_article, only: %i[show edit update destroy publish]
 
  def edit

Policy-based authorization in a Rails controller

authorization policy-object before-action
Intermediate 9 steps
typescript
import { inject } from '@angular/core';
import {
  CanActivateFn,
  Router,

Functional route guards in Angular

route-guards dependency-injection observables
Intermediate 5 steps
typescript
import {
  CanActivate,
  ExecutionContext,
  Injectable,

Role-based route guards in NestJS

authorization decorators metadata-reflection
Intermediate 8 steps
javascript
'use server'
 
import { revalidatePath } from 'next/cache'
import { redirect } from 'next/navigation'

How a Next.js Server Action updates a post

server-actions authorization validation
Intermediate 7 steps
php
<?php
 
namespace App\Policies;
 

How authorization policies gate updates in Laravel

authorization policies access control
Intermediate 7 steps
php
<?php
 
namespace App\Http\Requests;
 

How a Laravel FormRequest validates input

validation form-request input-sanitization
Intermediate 6 steps
ruby
class ArticlesController < ApplicationController
  before_action :authenticate_user!
  before_action :set_article, only: %i[show edit update destroy]
  before_action :authorize_owner!, only: %i[edit update destroy]

How before_action filters guard a Rails controller

filters authorization callbacks
Intermediate 9 steps