Skip to main content

Authorization in the App Layer: Using Casbin Flask Middleware

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

If your deployment environment doesn't support a service mesh like Envoy or an external authorization server (common in simpler, monolithic, or traditional hosting setups), you can certainly move the Casbin authorization check into your Flask application using middleware or decorators.

This approach centralizes authorization logic within the Python code, relying on dedicated extensions like flask-authz or Flask-Casbin.

SQLite Adapter for Casbin: Local Policy Storage Guide

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Using SQLite as the database adapter for Casbin policy storage is the ideal solution for local development, unit testing, and small-scale applications due to its lightweight, file-based nature.

In the Python Casbin ecosystem, this is achieved using the casbin-sqlalchemy-adapter, as SQLAlchemy natively supports SQLite without needing separate driver installations [2].

Implement Casbin sidecar pattern

· 5 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

1. The Casbin Sidecar Pattern

A sidecar is a helper container that runs alongside your main application container (the Flask app) inside the same Kubernetes Pod [4]. The sidecar, in this case, is the Envoy Proxy, which intercepts all incoming and outgoing traffic for your Flask application.

Centralized Authorization on GCP: Casbin, Envoy, and API Gateway

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Centralized Authorization on GCP: Casbin, Envoy, and API Gateway

Implementing authorization within a web application, especially in a microservices environment, can quickly lead to duplicated or inconsistent security logic. By leveraging the External Authorization Pattern using Envoy Proxy and Casbin, you can decouple security checks from your Flask application, making your architecture cleaner, more secure, and scalable.

This strategy is particularly effective on Google Cloud Platform (GCP) when using services like API Gateway or Cloud Endpoints as the entry point, and Firestore as the persistent policy backend.

Casbin Hierarchical RBAC Maintenance: Static Structure vs. Dynamic Roles

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

A common misconception about using Casbin Hierarchical RBAC is that the entire policy storage must be updated every time a user performs an action or changes state. This is incorrect. The system is designed to separate the static, structural hierarchy (which rarely changes) from the dynamic user assignments (which change frequently).

The efficiency of Hierarchical RBAC lies in this separation, minimizing the required policy updates and reducing redundancy.

Casbin RBAC vs. Casbin RBAC with Hierarchical Roles

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

The choice between standard Casbin RBAC (Role-Based Access Control) and Casbin RBAC with Hierarchical Roles largely depends on the complexity of your application's user structure and the need for role inheritance.

Both models use a similar policy structure in Casbin's configuration files (models and policies), but the hierarchical model provides a powerful shortcut for managing permissions in complex organizations.

Postman clear cache response

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

While Postman doesn't have a single "Clear Cache" button that directly affects API results (as it doesn't cache external API responses), the core issue often lies in two areas that mimic caching: DNS resolution and request state persistence.

Check history of specific line in vscode

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

You can check the history of a specific line in VS Code using the built-in Git Blame feature or the Timeline view. For a much more powerful experience, the free GitLens extension is highly recommended.

How to squash commits

· 6 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Squashing commits is a common Git operation that combines multiple commits into a single, cleaner commit. This is crucial for keeping your branch history tidy before merging into a main branch (like main or master), making the project history easier to read and revert [1].

The primary tool for squashing commits is interactive rebase (git rebase -i).