Download the PHP package innis/nostr-sign-in without Composer

On this page you can find all versions of the php package innis/nostr-sign-in. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nostr-sign-in

innis/nostr-sign-in

CI

NIP-98 cookie-session sign-in for Symfony applications, riding Symfony Security. The browser signs exactly one NIP-98 proof; a custom authenticator verifies it and the firewall carries the identity in the session. Roles, #[IsGranted], access_control, voters and CSRF are all Symfony's — this package provides the nostr-specific identity pieces and nothing the framework already maintains.

A plain library over Symfony components — not a bundle, never dependent on framework-bundle; the consumer brings symfony/security-bundle and its own firewall. Applications that authenticate per request instead of per session need only innis/nostr-core, not this package.

Read docs/adr/ before judging or changing the design; the decisions and their costs are recorded there.

Install

Requires PHP 8.4 and Symfony 8.

What the package provides

What the host must supply

login_throttling (bring symfony/security-bundle's companion, composer require symfony/rate-limiter) composes with the authenticator by design: the passport carries the claimed key and defers verification to its credentials, so the throttler counts failed proofs per claimed key and per IP before any signature is checked. A header that does not even decode never reaches the throttler — there is no identity to count it against. Symfony's user_checker firewall option also composes untouched: implement UserCheckerInterface to refuse a banned or disabled pubkey at sign-in. To revoke a key mid-session, supply your own provider whose refreshUser throws UserNotFoundException for it — the firewall drops the token on the very next request.

The prefix appears in three places that must agree: this route prefix, SameOriginActionSubscriber's $guardedPrefix (which writes are origin-checked), and RefusalResponder's $scriptedPrefix (which callers get JSON refusals instead of a redirect home). All three default to /action; choosing another prefix means configuring the two constructor arguments beside it.

Then secure whatever needs securing with the framework's own vocabulary: #[IsGranted('ROLE_ADMIN')], access_control, or a voter for per-object questions.

Alongside an existing login

Nothing in the package demands its own user class. The authenticator identifies users by pubkey hex, so you may point the firewall at your own provider and resolve your own users — link a nostr key to an existing account — as long as that user's getUserIdentifier() returns the pubkey hex. The success response, CurrentUserInterface and the PublicKey argument resolver all read the identifier off the token, never a class. A token whose identifier is not a pubkey (your form-login users, say) simply reads as nobody to the nostr side. The sign-out responder answers only its own nostr_sign_out route, so an existing logout keeps its own rendering.

Provisioning and linking on first sign-in is a listener on Symfony's own LoginSuccessEvent — create your account row, or attach the key to the signed-in person's existing account, keyed by the pubkey:

The one thing Symfony will make you choose is the entry point: a firewall has exactly one, so if form_login already answers your 401s, either give the nostr surface its own firewall pattern, or write a small entry point that delegates by path and keep RefusalResponder for the nostr routes. And if your application needs a different wire shape than {success, pubkey, npub}, hand Nip98Authenticator your own AuthenticationSuccessHandlerInterface / AuthenticationFailureHandlerInterface — the same optional constructor seam Symfony's own AccessTokenAuthenticator exposes.

Roles from your own data

ConfiguredKeyRoleAssigner is the floor, not the mechanism: the provider depends only on RoleAssignerInterface, so a site whose roles are data implements the port against its own store and re-points one alias line — nothing else changes:

Two properties to know: roles are re-read on every request (the provider deliberately reloads through the assigner), and a changed role set deauthenticates the session on its very next request — Symfony freezes the token's roles at login, so the safe response to a flipped flag is a forced re-sign-in under the new roles, never a session silently keeping old powers. If the per-request query ever matters, wrap your assigner in a caching decorator rather than changing it. Keep the assigner to coarse roles: "is an editor at all" belongs here, "may edit this magazine" belongs in a voter consulting your own store.

Example

Signs a real proof with a generated key, authenticates it, shows the roles the firewall would carry, and shows the same proof being refused on replay.

Development

License

MIT License. See LICENSE file for details.


All versions of nostr-sign-in with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
innis/nostr-core Version ^0.11
psr/cache Version ^3
symfony/event-dispatcher Version ^8.1.5
symfony/http-foundation Version ^8.1.11
symfony/http-kernel Version ^8.1.11
symfony/routing Version ^8.1.11
symfony/security-core Version ^8.1.11
symfony/security-http Version ^8.1.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package innis/nostr-sign-in contains the following files

Loading the files please wait ...