Himanshu SharmaSoftware engineer
Let’s talk

CodeIgniter 4 · Lesson 21 of 30

CodeIgniter authentication: evaluate Shield and access rules

Design bookshop access rules and identify verified Shield capabilities without presenting an uninstalled package as a completed login system.

15 minAccess boundariesUpdated 14 November 2026

Awaiting technical review. This lesson is readable but not yet listed in search engines.

By the end of this lessonDesign bookshop access rules and identify verified Shield capabilities without presenting an uninstalled package as a completed login system.

After this lesson you can distinguish authentication from authorization and write an access policy for the bookshop before adding a login package. You will also identify what the official documentation confirms about CodeIgniter Shield. This is an authentication-design lesson, not an unverified package installation walkthrough.

Identity and permission answer different questions

Authentication establishes who a caller is through a trustworthy process. Authorization decides what that identity may do. A logged-in customer does not automatically become a catalogue editor. A valid session identifier does not by itself prove that its associated user has a particular permission.

For Paper Lantern Bookshop, public visitors can read catalogue pages and the read-only JSON interface. Catalogue changes and cover uploads are editor operations. A missing or insufficient identity must not gain access simply by knowing a URL or changing a submitted field.

text
Public reader: list books, open a book, read catalogue JSON
Catalogue editor: permitted book changes after verified authentication
Unidentified caller: no catalogue writes and no cover uploads
Before authentication integration: deny every external write

This is an application policy sketch, not terminal output. It gives an authentication integration a measurable target. The framework cannot infer the intended policy from controller names, button labels or the presence of a session library.

What is verified about Shield

CodeIgniter's official Authentication page identifies Shield as its official authentication and authorization framework for version 4. The official Shield repository README, fetched for this course as of 2026-11, describes session-based and access-token authentication as well as groups and permissions. That confirms broad capabilities, not that any particular configuration is installed in our app.

Shield was not installed in the verified bookshop. No Shield version, setup command, helper signature or completed login flow is taught here. Before adopting it, select a stable compatible release, read that release's installation and upgrade instructions, and verify its actual behavior in an isolated workspace. A package's general README is not enough evidence for a complete version-specific setup tutorial.

The course teaches core CodeIgniter 4.7.6. Authentication package releases have their own lifecycle. Do not assume the framework's version number names the Shield version, and do not paste a development-branch example into a production release without checking compatibility.

Plan the integration before opening routes

A reviewed integration needs account creation rules, login and logout behavior, password handling through the package's supported facilities, recovery policy and session security. Email-dependent flows also need a controlled mail setup for testing. These responsibilities are real work, not details to hide behind a single installation command.

For authorization, map editor capabilities to the actual bookshop operations. Creating, updating, deleting and uploading may need different permissions. If records later belong to users, check ownership or scope for each record. A role check alone is not always enough to prevent one user editing another user's record.

Do not accept an editor flag from a form and store it in the session as proof of permission. The client controls submitted fields. Permission state must come from trusted application records and the reviewed authentication system. Similarly, never compare plaintext stored passwords in an improvised controller.

Use denial until the policy is implemented

The previous lesson's CatalogueReadOnly filter provides a simple interim boundary: everyone is denied a write. This is intentionally restrictive. It allows a public reading demonstration without claiming that an unfinished login flow protects local CRUD exercises.

When an integration is ready, replace denial with documented identity and permission checks, then test both permitted and denied requests. Keep denial as the default when identity is absent or cannot be verified. Do not interpret an authentication service error as a reason to allow the write.

Build an access test matrix

Test public reads without a session. Test denied writes without identity. Test a valid but insufficient identity. Test an authorized editor. For each denied mutation, verify the record or upload state remains unchanged. Include alternative methods and every route that reaches a mutation.

The fetched official Authentication guide and Shield repository README support the limited capability statements above. The README link points to development documentation, so use it for orientation only, not as a version-pinned integration recipe.

Common mistakes

Equating login with unlimited permission grants too much access. Trusting a submitted role lets callers assign their own authority. Assuming a hidden admin link protects a route ignores direct requests. Finally, claiming Shield is configured because it is recommended by the framework skips installation, configuration and behavioral testing. Keep that unfinished work explicit.

Exercise

A signed-in reader sends a valid CSRF token and a valid new title to the update route. Should the request succeed under the policy above? Explain which boundary answers the question and what the current read-only demonstration should do.

Show an answer

No. The caller is authenticated but lacks the editor permission required for a catalogue write. Authorization decides this. Until a reviewed integration exists, the demonstration denies every external write, including requests with otherwise valid input and tokens. No stored title should change.

Previous lesson · Next lesson · Related: explicit routes

Key points

  • Authentication establishes identity; authorization grants specific actions.
  • Shield is the official CodeIgniter authentication and authorization framework.
  • The verified course app does not install Shield and must deny external writes.

Check yourself

1. Can a signed-in reader automatically edit books?
2. Was Shield installed in the verified course app?
3. Where must permission state come from?