Skip to content

Publish bwh-auth (npm) and auth-laravel (Packagist) from CI on tag - #15

Merged
bherila merged 4 commits into
mainfrom
chore/release-automation
Jun 19, 2026
Merged

Publish bwh-auth (npm) and auth-laravel (Packagist) from CI on tag#15
bherila merged 4 commits into
mainfrom
chore/release-automation

Conversation

@bherila

@bherila bherila commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add .github/workflows/release.yml:
    • bwh-auth-v* tag → build the JS package, publish to npm via OIDC trusted publishing (with provenance), and create a GitHub release with the packed .tgz.
    • v* tag → refresh bherila/auth-laravel on Packagist.
  • Simplify ui/scripts/release.mjs to only bump → tag → push; publishing and the GitHub release are now CI's job, so it no longer publishes locally or requires gh.

Required configuration

  • npm trusted publisher (already added): org bherila, repo auth, workflow filename release.yml, environment prod. No NPM_TOKEN secret needed — the npm job uses id-token: write OIDC.
  • prod environment secret: PACKAGIST_TOKEN.
  • The Packagist username is inlined as bherila in the workflow — change it if the token owner differs.

🤖 Generated with Claude Code

bherila and others added 4 commits June 13, 2026 17:19
…footguns

Four integration bugs surfaced in a consuming app (vora); this commit
prevents the package-preventable ones:

**Finding 1 (P1 — access-control bypass)**
- Add `AuthUserPolicy::canLogin()` to the contract with a docblock
  explaining it is the single gate for account state (active, approved,
  not disabled). The default implementation duck-types `$user->canLogin()`
  then falls back to `is_disabled`, matching the previous
  `canPasskeyLogin()` logic.
- `DefaultAuthUserPolicy::canPasskeyLogin()` now delegates to
  `canLogin()` so both code paths share one implementation.
- New `RequireActiveUser` middleware calls `policy->canLogin()` and
  aborts 403 when the user is not allowed in. Applied automatically on
  all package audit-log routes (previously only `auth` middleware was
  applied, letting a pending/disabled admin reach the admin endpoint if
  their Gate ability only checked role).
- Config comment on `audit.admin_ability` warns that the gate definition
  must check both role and account state.

**Finding 2 (P1 — lockout-after-migration)**
- Package does not own the `approved_at` column (it is app-side), so
  there is nothing to migrate-fix. Added prominent README guidance with
  a code example showing how to backfill the column in the migration that
  adds it, so integrators do not lock out existing users.

**Finding 3 (P2 — onboarding redirect divergence)**
- Package does not ship an email-verification controller (app-owned), so
  the hardcoded `/pending` redirect was not in this repo.
- Added README guidance: after email verification the app must call
  `AuthUserPolicy::redirectAfterLogin()` (not a hardcoded path), so an
  already-approved user who verifies their email is sent to the correct
  destination instead of the pending page.

**Finding 4 (P3 — dropdown outside-click)**
- The package ships no navbar/dropdown/menu components; this bug is
  entirely app-side. No change.

Tests: 7 new assertions covering `canLogin()`, the `is_disabled` fallback,
the `canPasskeyLogin()` delegation, and the middleware pass/block/unauthenticated
cases. All 40 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adding canLogin() to the AuthUserPolicy contract is a BC break for direct
implementers. Document that this must ship as v0.5.0 (not a 0.4.x patch, which
^0.4 consumers would auto-pull and fatal on) and how integrators migrate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add .github/workflows/release.yml: pushing a `bwh-auth-v*` tag builds the JS
package, publishes it to npm, and creates a GitHub release with the packed
tarball; pushing a `v*` tag refreshes the PHP package on Packagist. Both jobs
use the `prod` environment for the NPM_TOKEN / PACKAGIST_TOKEN secrets.

Simplify release.mjs to only bump, tag, and push — publishing and the GitHub
release are now CI's responsibility, so it no longer publishes locally or needs
gh. Pushing the tag is the single trigger.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The npm job now requests an id-token and publishes via `npm publish --provenance`,
letting npm exchange the GitHub OIDC token for a short-lived credential. Drops
the NPM_TOKEN secret entirely and attests provenance automatically. Upgrades npm
to >= 11.5.0 first (required for trusted publishing). The prod environment is
kept so the OIDC claim matches the trusted-publisher environment scope.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bherila
bherila merged commit 8d599d2 into main Jun 19, 2026
4 checks passed
@bherila
bherila deleted the chore/release-automation branch June 19, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant