Skip to content

Instantly share code, notes, and snippets.

@Bonny-kato
Bonny-kato / access-control.md
Last active October 6, 2025 15:59
The document outlines implementing access control in a React app using RBAC and ABAC methods, highlighting utilities for verifying user roles, permissions, and attributes to ensure authorized access based on roles or a set of user/environmental attributes.

Access Control in React Based Apps

Following user authentication, implementing access control in a React app involves managing and restricting user permissions to access certain components or pages based on their roles, attributes, and permissions. This ensures that users can only access resources they're authorized to handle or perform actions permitted for them. Two common types of access control are RBAC (Role-Based Access Control) and ABAC (Attribute-Based Access Control).

Introduction

Role-Based Access Control (RBAC)

// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@mul14
mul14 / 00_etc-hosts.md
Last active October 14, 2025 05:47
/etc/hosts for Vimeo, Reddit, Imgur, GitHub, DigitalOcean, dll

Unblock Steam, Vimeo, Reddit, Imgur, GitHub, DigitalOcean, NPM, PayPal, dll

Saya support Internet Positif untuk memblokir porn, situs judi, dan hal-hal ilegal lainnya. Tapi pemerintah dan ISP sangat konyol karena tidak mengizinkan akses ke Vimeo, Reddit, Imgur, Netflix--yang mana bukanlah situs dengan konten utama ilegal.

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows