Browse Source

Update packages. Change authenticator.

imwald
Nuša Pukšič 1 year ago
parent
commit
0be39b6ccb
  1. 4
      .github/workflows/ci.yml
  2. 4
      Dockerfile
  3. 465
      composer.lock
  4. 38
      migrations/Version20241205135004.php
  5. 4
      src/Entity/Event.php
  6. 5
      src/Entity/User.php
  7. 25
      src/Repository/UserEntityRepository.php
  8. 28
      src/Security/NostrAuthenticator.php
  9. 7
      src/Service/NostrClient.php

4
.github/workflows/ci.yml

@ -43,18 +43,15 @@ jobs:
run: curl -v --fail-with-body http://localhost run: curl -v --fail-with-body http://localhost
- -
name: Check HTTPS reachability name: Check HTTPS reachability
if: false # Remove this line when the homepage will be configured, or change the path to check
run: curl -vk --fail-with-body https://localhost run: curl -vk --fail-with-body https://localhost
- -
name: Check Mercure reachability name: Check Mercure reachability
run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test
- -
name: Create test database name: Create test database
if: false # Remove this line if Doctrine ORM is installed
run: docker compose exec -T php bin/console -e test doctrine:database:create run: docker compose exec -T php bin/console -e test doctrine:database:create
- -
name: Run migrations name: Run migrations
if: false # Remove this line if Doctrine Migrations is installed
run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction
- -
name: Run PHPUnit name: Run PHPUnit
@ -62,7 +59,6 @@ jobs:
run: docker compose exec -T php bin/phpunit run: docker compose exec -T php bin/phpunit
- -
name: Doctrine Schema Validator name: Doctrine Schema Validator
if: false # Remove this line if Doctrine ORM is installed
run: docker compose exec -T php bin/console -e test doctrine:schema:validate run: docker compose exec -T php bin/console -e test doctrine:schema:validate
lint: lint:
name: Docker Lint name: Docker Lint

4
Dockerfile

@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
file \ file \
gettext \ gettext \
git \ git \
libnss3-tools \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN set -eux; \ RUN set -eux; \
@ -41,8 +42,7 @@ ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d"
###> recipes ### ###> recipes ###
###> doctrine/doctrine-bundle ### ###> doctrine/doctrine-bundle ###
RUN install-php-extensions pdo RUN install-php-extensions pdo pdo_pgsql
RUN install-php-extensions pdo_pgsql
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###
###< recipes ### ###< recipes ###

465
composer.lock generated

@ -1354,182 +1354,42 @@
}, },
"time": "2024-10-21T18:21:57+00:00" "time": "2024-10-21T18:21:57+00:00"
}, },
{
"name": "fgrosse/phpasn1",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/fgrosse/PHPASN1.git",
"reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/42060ed45344789fb9f21f9f1864fc47b9e3507b",
"reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "~2.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"suggest": {
"ext-bcmath": "BCmath is the fallback extension for big integer calculations",
"ext-curl": "For loading OID information from the web if they have not bee defined statically",
"ext-gmp": "GMP is the preferred extension for big integer calculations",
"phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"FG\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Friedrich Große",
"email": "friedrich.grosse@gmail.com",
"homepage": "https://github.com/FGrosse",
"role": "Author"
},
{
"name": "All contributors",
"homepage": "https://github.com/FGrosse/PHPASN1/contributors"
}
],
"description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.",
"homepage": "https://github.com/FGrosse/PHPASN1",
"keywords": [
"DER",
"asn.1",
"asn1",
"ber",
"binary",
"decoding",
"encoding",
"x.509",
"x.690",
"x509",
"x690"
],
"support": {
"issues": "https://github.com/fgrosse/PHPASN1/issues",
"source": "https://github.com/fgrosse/PHPASN1/tree/v2.5.0"
},
"abandoned": true,
"time": "2022-12-19T11:08:26+00:00"
},
{
"name": "lcobucci/clock",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/clock.git",
"reference": "fb533e093fd61321bfcbac08b131ce805fe183d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/fb533e093fd61321bfcbac08b131ce805fe183d3",
"reference": "fb533e093fd61321bfcbac08b131ce805fe183d3",
"shasum": ""
},
"require": {
"php": "^8.0",
"stella-maris/clock": "^0.1.4"
},
"require-dev": {
"infection/infection": "^0.26",
"lcobucci/coding-standard": "^8.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Lcobucci\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Luís Cobucci",
"email": "lcobucci@gmail.com"
}
],
"description": "Yet another clock abstraction",
"support": {
"issues": "https://github.com/lcobucci/clock/issues",
"source": "https://github.com/lcobucci/clock/tree/2.2.0"
},
"funding": [
{
"url": "https://github.com/lcobucci",
"type": "github"
},
{
"url": "https://www.patreon.com/lcobucci",
"type": "patreon"
}
],
"time": "2022-04-19T19:34:17+00:00"
},
{ {
"name": "lcobucci/jwt", "name": "lcobucci/jwt",
"version": "4.0.4", "version": "5.4.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/lcobucci/jwt.git", "url": "https://github.com/lcobucci/jwt.git",
"reference": "55564265fddf810504110bd68ca311932324b0e9" "reference": "ea1ce71cbf9741e445a5914e2f67cdbb484ff712"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/55564265fddf810504110bd68ca311932324b0e9", "url": "https://api.github.com/repos/lcobucci/jwt/zipball/ea1ce71cbf9741e445a5914e2f67cdbb484ff712",
"reference": "55564265fddf810504110bd68ca311932324b0e9", "reference": "ea1ce71cbf9741e445a5914e2f67cdbb484ff712",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-mbstring": "*",
"ext-openssl": "*", "ext-openssl": "*",
"lcobucci/clock": "^2.0", "ext-sodium": "*",
"php": "^7.4 || ^8.0" "php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"psr/clock": "^1.0"
}, },
"require-dev": { "require-dev": {
"infection/infection": "^0.20", "infection/infection": "^0.29",
"lcobucci/coding-standard": "^6.0", "lcobucci/clock": "^3.2",
"mikey179/vfsstream": "^1.6", "lcobucci/coding-standard": "^11.0",
"phpbench/phpbench": "^0.17", "phpbench/phpbench": "^1.2",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^0.12", "phpstan/phpstan": "^1.10.7",
"phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-phpunit": "^1.3.10",
"phpstan/phpstan-strict-rules": "^0.12", "phpstan/phpstan-strict-rules": "^1.5.0",
"phpunit/php-invoker": "^3.1", "phpunit/phpunit": "^11.1"
"phpunit/phpunit": "^9.4"
}, },
"type": "library", "suggest": {
"extra": { "lcobucci/clock": ">= 3.2"
"branch-alias": {
"dev-master": "4.0-dev"
}
}, },
"type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Lcobucci\\JWT\\": "src" "Lcobucci\\JWT\\": "src"
@ -1553,7 +1413,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/lcobucci/jwt/issues", "issues": "https://github.com/lcobucci/jwt/issues",
"source": "https://github.com/lcobucci/jwt/tree/4.0.4" "source": "https://github.com/lcobucci/jwt/tree/5.4.2"
}, },
"funding": [ "funding": [
{ {
@ -1565,7 +1425,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2021-09-28T19:18:28+00:00" "time": "2024-11-07T12:54:35+00:00"
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
@ -2634,65 +2494,18 @@
}, },
"time": "2024-01-09T14:57:04+00:00" "time": "2024-01-09T14:57:04+00:00"
}, },
{
"name": "stella-maris/clock",
"version": "0.1.7",
"source": {
"type": "git",
"url": "https://github.com/stella-maris-solutions/clock.git",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"psr/clock": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"StellaMaris\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Heigl",
"role": "Maintainer"
}
],
"description": "A pre-release of the proposed PSR-20 Clock-Interface",
"homepage": "https://gitlab.com/stella-maris/clock",
"keywords": [
"clock",
"datetime",
"point in time",
"psr20"
],
"support": {
"source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7"
},
"time": "2022-11-25T16:15:06+00:00"
},
{ {
"name": "swentel/nostr-php", "name": "swentel/nostr-php",
"version": "1.5.1", "version": "1.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nostrver-se/nostr-php.git", "url": "https://github.com/nostrver-se/nostr-php.git",
"reference": "93091fae55173b8e0776199a8de08014441a15d4" "reference": "cca30f99b07d6f2d1d645f670ac56d3c36b65bd1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nostrver-se/nostr-php/zipball/93091fae55173b8e0776199a8de08014441a15d4", "url": "https://api.github.com/repos/nostrver-se/nostr-php/zipball/cca30f99b07d6f2d1d645f670ac56d3c36b65bd1",
"reference": "93091fae55173b8e0776199a8de08014441a15d4", "reference": "cca30f99b07d6f2d1d645f670ac56d3c36b65bd1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2702,7 +2515,7 @@
"php": ">=8.1 <8.5", "php": ">=8.1 <8.5",
"phrity/websocket": "^3.0", "phrity/websocket": "^3.0",
"simplito/elliptic-php": "^1.0", "simplito/elliptic-php": "^1.0",
"uma/phpecc": "^0.1.3" "uma/phpecc": "^0.2.0"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.51", "friendsofphp/php-cs-fixer": "^3.51",
@ -2744,9 +2557,9 @@
"chat": "https://t.me/nostr_php", "chat": "https://t.me/nostr_php",
"issue": "https://github.com/swentel/nostr-php/issues", "issue": "https://github.com/swentel/nostr-php/issues",
"issues": "https://github.com/nostrver-se/nostr-php/issues", "issues": "https://github.com/nostrver-se/nostr-php/issues",
"source": "https://github.com/nostrver-se/nostr-php/tree/1.5.1" "source": "https://github.com/nostrver-se/nostr-php/tree/1.5.2"
}, },
"time": "2024-11-24T22:06:24+00:00" "time": "2024-12-05T09:03:53+00:00"
}, },
{ {
"name": "symfony/asset", "name": "symfony/asset",
@ -2898,16 +2711,16 @@
}, },
{ {
"name": "symfony/cache", "name": "symfony/cache",
"version": "v7.1.7", "version": "v7.1.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/cache.git", "url": "https://github.com/symfony/cache.git",
"reference": "23b61c9592ee72233c31625f0ae805dd1571e928" "reference": "18e0ba45a50032aa53dfebf830ec2980bb131591"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/cache/zipball/23b61c9592ee72233c31625f0ae805dd1571e928", "url": "https://api.github.com/repos/symfony/cache/zipball/18e0ba45a50032aa53dfebf830ec2980bb131591",
"reference": "23b61c9592ee72233c31625f0ae805dd1571e928", "reference": "18e0ba45a50032aa53dfebf830ec2980bb131591",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2975,7 +2788,7 @@
"psr6" "psr6"
], ],
"support": { "support": {
"source": "https://github.com/symfony/cache/tree/v7.1.7" "source": "https://github.com/symfony/cache/tree/v7.1.9"
}, },
"funding": [ "funding": [
{ {
@ -2991,20 +2804,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-05T15:34:55+00:00" "time": "2024-11-20T10:42:04+00:00"
}, },
{ {
"name": "symfony/cache-contracts", "name": "symfony/cache-contracts",
"version": "v3.5.0", "version": "v3.5.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/cache-contracts.git", "url": "https://github.com/symfony/cache-contracts.git",
"reference": "df6a1a44c890faded49a5fca33c2d5c5fd3c2197" "reference": "15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/cache-contracts/zipball/df6a1a44c890faded49a5fca33c2d5c5fd3c2197", "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b",
"reference": "df6a1a44c890faded49a5fca33c2d5c5fd3c2197", "reference": "15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3051,7 +2864,7 @@
"standards" "standards"
], ],
"support": { "support": {
"source": "https://github.com/symfony/cache-contracts/tree/v3.5.0" "source": "https://github.com/symfony/cache-contracts/tree/v3.5.1"
}, },
"funding": [ "funding": [
{ {
@ -3067,7 +2880,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-04-18T09:32:20+00:00" "time": "2024-09-25T14:20:29+00:00"
}, },
{ {
"name": "symfony/clock", "name": "symfony/clock",
@ -3460,16 +3273,16 @@
}, },
{ {
"name": "symfony/doctrine-bridge", "name": "symfony/doctrine-bridge",
"version": "v7.1.6", "version": "v7.1.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/doctrine-bridge.git", "url": "https://github.com/symfony/doctrine-bridge.git",
"reference": "3fcfb37b738def92757b6ac5365a3147b2e2dd36" "reference": "893cc4fa0f218d6e88efbe58397e2b42167648e1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/3fcfb37b738def92757b6ac5365a3147b2e2dd36", "url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/893cc4fa0f218d6e88efbe58397e2b42167648e1",
"reference": "3fcfb37b738def92757b6ac5365a3147b2e2dd36", "reference": "893cc4fa0f218d6e88efbe58397e2b42167648e1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3499,7 +3312,7 @@
}, },
"require-dev": { "require-dev": {
"doctrine/collections": "^1.0|^2.0", "doctrine/collections": "^1.0|^2.0",
"doctrine/data-fixtures": "^1.1", "doctrine/data-fixtures": "^1.1|^2",
"doctrine/dbal": "^3.6|^4", "doctrine/dbal": "^3.6|^4",
"doctrine/orm": "^2.15|^3", "doctrine/orm": "^2.15|^3",
"psr/log": "^1|^2|^3", "psr/log": "^1|^2|^3",
@ -3548,7 +3361,7 @@
"description": "Provides integration for Doctrine with various Symfony components", "description": "Provides integration for Doctrine with various Symfony components",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/doctrine-bridge/tree/v7.1.6" "source": "https://github.com/symfony/doctrine-bridge/tree/v7.1.9"
}, },
"funding": [ "funding": [
{ {
@ -3564,20 +3377,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-10-18T09:42:06+00:00" "time": "2024-11-25T12:02:18+00:00"
}, },
{ {
"name": "symfony/dotenv", "name": "symfony/dotenv",
"version": "v7.1.6", "version": "v7.1.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dotenv.git", "url": "https://github.com/symfony/dotenv.git",
"reference": "56a10f3032a6c2f085b13bc429e9d78a2c895dc4" "reference": "245d1afe223664d2276afb75177d8988c328fb78"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/56a10f3032a6c2f085b13bc429e9d78a2c895dc4", "url": "https://api.github.com/repos/symfony/dotenv/zipball/245d1afe223664d2276afb75177d8988c328fb78",
"reference": "56a10f3032a6c2f085b13bc429e9d78a2c895dc4", "reference": "245d1afe223664d2276afb75177d8988c328fb78",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3622,7 +3435,7 @@
"environment" "environment"
], ],
"support": { "support": {
"source": "https://github.com/symfony/dotenv/tree/v7.1.6" "source": "https://github.com/symfony/dotenv/tree/v7.1.9"
}, },
"funding": [ "funding": [
{ {
@ -3638,7 +3451,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-09-28T11:14:12+00:00" "time": "2024-11-27T11:17:28+00:00"
}, },
{ {
"name": "symfony/error-handler", "name": "symfony/error-handler",
@ -4316,23 +4129,23 @@
}, },
{ {
"name": "symfony/http-client", "name": "symfony/http-client",
"version": "v7.1.8", "version": "v7.1.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-client.git", "url": "https://github.com/symfony/http-client.git",
"reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a" "reference": "2ec49720a38a8041673ba4c42512bfd845218c56"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", "url": "https://api.github.com/repos/symfony/http-client/zipball/2ec49720a38a8041673ba4c42512bfd845218c56",
"reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", "reference": "2ec49720a38a8041673ba4c42512bfd845218c56",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.2", "php": ">=8.2",
"psr/log": "^1|^2|^3", "psr/log": "^1|^2|^3",
"symfony/deprecation-contracts": "^2.5|^3", "symfony/deprecation-contracts": "^2.5|^3",
"symfony/http-client-contracts": "^3.4.1", "symfony/http-client-contracts": "~3.4.3|^3.5.1",
"symfony/service-contracts": "^2.5|^3" "symfony/service-contracts": "^2.5|^3"
}, },
"conflict": { "conflict": {
@ -4390,7 +4203,7 @@
"http" "http"
], ],
"support": { "support": {
"source": "https://github.com/symfony/http-client/tree/v7.1.8" "source": "https://github.com/symfony/http-client/tree/v7.1.9"
}, },
"funding": [ "funding": [
{ {
@ -4406,7 +4219,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-13T13:40:27+00:00" "time": "2024-11-27T11:52:45+00:00"
}, },
{ {
"name": "symfony/http-client-contracts", "name": "symfony/http-client-contracts",
@ -5629,16 +5442,16 @@
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v7.1.6", "version": "v7.1.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
"reference": "66a2c469f6c22d08603235c46a20007c0701ea0a" "reference": "a27bb8e0cc3ca4baf17159d053910c9736c3aa4c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/66a2c469f6c22d08603235c46a20007c0701ea0a", "url": "https://api.github.com/repos/symfony/routing/zipball/a27bb8e0cc3ca4baf17159d053910c9736c3aa4c",
"reference": "66a2c469f6c22d08603235c46a20007c0701ea0a", "reference": "a27bb8e0cc3ca4baf17159d053910c9736c3aa4c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5690,7 +5503,7 @@
"url" "url"
], ],
"support": { "support": {
"source": "https://github.com/symfony/routing/tree/v7.1.6" "source": "https://github.com/symfony/routing/tree/v7.1.9"
}, },
"funding": [ "funding": [
{ {
@ -5706,7 +5519,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-10-01T08:31:23+00:00" "time": "2024-11-13T16:12:35+00:00"
}, },
{ {
"name": "symfony/runtime", "name": "symfony/runtime",
@ -6890,20 +6703,21 @@
}, },
{ {
"name": "symfony/ux-live-component", "name": "symfony/ux-live-component",
"version": "v2.21.0", "version": "v2.22.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/ux-live-component.git", "url": "https://github.com/symfony/ux-live-component.git",
"reference": "1cc963a50a31a8ca92fbd145b29b27231b199b1b" "reference": "2df6a25f25788864e65cb8812d85e14ef80b6b44"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/ux-live-component/zipball/1cc963a50a31a8ca92fbd145b29b27231b199b1b", "url": "https://api.github.com/repos/symfony/ux-live-component/zipball/2df6a25f25788864e65cb8812d85e14ef80b6b44",
"reference": "1cc963a50a31a8ca92fbd145b29b27231b199b1b", "reference": "2df6a25f25788864e65cb8812d85e14ef80b6b44",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.1", "php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3.0",
"symfony/property-access": "^5.4.5|^6.0|^7.0", "symfony/property-access": "^5.4.5|^6.0|^7.0",
"symfony/stimulus-bundle": "^2.9", "symfony/stimulus-bundle": "^2.9",
"symfony/ux-twig-component": "^2.8", "symfony/ux-twig-component": "^2.8",
@ -6936,8 +6750,8 @@
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/ux", "url": "https://github.com/symfony/ux",
"url": "https://github.com/symfony/ux" "name": "symfony/ux"
} }
}, },
"autoload": { "autoload": {
@ -6963,7 +6777,7 @@
"twig" "twig"
], ],
"support": { "support": {
"source": "https://github.com/symfony/ux-live-component/tree/v2.21.0" "source": "https://github.com/symfony/ux-live-component/tree/v2.22.0"
}, },
"funding": [ "funding": [
{ {
@ -6979,20 +6793,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-10-15T10:36:54+00:00" "time": "2024-11-29T15:31:04+00:00"
}, },
{ {
"name": "symfony/ux-twig-component", "name": "symfony/ux-twig-component",
"version": "v2.21.0", "version": "v2.22.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/ux-twig-component.git", "url": "https://github.com/symfony/ux-twig-component.git",
"reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d" "reference": "03177a494399fbdcbb1f5f2aee017ccf8df581d9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/5b60b239fffcb04fc8bdb2a5a4001d19442d575d", "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/03177a494399fbdcbb1f5f2aee017ccf8df581d9",
"reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d", "reference": "03177a494399fbdcbb1f5f2aee017ccf8df581d9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7019,8 +6833,8 @@
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/ux", "url": "https://github.com/symfony/ux",
"url": "https://github.com/symfony/ux" "name": "symfony/ux"
} }
}, },
"autoload": { "autoload": {
@ -7046,7 +6860,7 @@
"twig" "twig"
], ],
"support": { "support": {
"source": "https://github.com/symfony/ux-twig-component/tree/v2.21.0" "source": "https://github.com/symfony/ux-twig-component/tree/v2.22.0"
}, },
"funding": [ "funding": [
{ {
@ -7062,7 +6876,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-10-05T22:11:16+00:00" "time": "2024-11-23T06:59:34+00:00"
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
@ -7379,7 +7193,7 @@
}, },
{ {
"name": "twig/extra-bundle", "name": "twig/extra-bundle",
"version": "v3.15.0", "version": "v3.16.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/twig-extra-bundle.git", "url": "https://github.com/twigphp/twig-extra-bundle.git",
@ -7437,7 +7251,7 @@
"twig" "twig"
], ],
"support": { "support": {
"source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.15.0" "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.16.0"
}, },
"funding": [ "funding": [
{ {
@ -7453,16 +7267,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v3.15.0", "version": "v3.16.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02" "reference": "475ad2dc97d65d8631393e721e7e44fb544f0561"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/2d5b3964cc21d0188633d7ddce732dc8e874db02", "url": "https://api.github.com/repos/twigphp/Twig/zipball/475ad2dc97d65d8631393e721e7e44fb544f0561",
"reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02", "reference": "475ad2dc97d65d8631393e721e7e44fb544f0561",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7473,6 +7287,7 @@
"symfony/polyfill-php81": "^1.29" "symfony/polyfill-php81": "^1.29"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "^2.0",
"psr/container": "^1.0|^2.0", "psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
}, },
@ -7516,7 +7331,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/twigphp/Twig/issues", "issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.15.0" "source": "https://github.com/twigphp/Twig/tree/v3.16.0"
}, },
"funding": [ "funding": [
{ {
@ -7528,34 +7343,108 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-17T15:59:19+00:00" "time": "2024-11-29T08:27:05+00:00"
},
{
"name": "uma/phpasn1",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/1ma/PHPASN1.git",
"reference": "dd805d3157ddc90515ee13562a9bb241c68f4f88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/1ma/PHPASN1/zipball/dd805d3157ddc90515ee13562a9bb241c68f4f88",
"reference": "dd805d3157ddc90515ee13562a9bb241c68f4f88",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.0",
"phpunit/phpunit": "^9.6"
},
"suggest": {
"ext-bcmath": "BCmath is the fallback extension for big integer calculations",
"ext-curl": "For loading OID information from the web if they have not bee defined statically",
"ext-gmp": "GMP is the preferred extension for big integer calculations",
"phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"FG\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Friedrich Große",
"email": "friedrich.grosse@gmail.com",
"homepage": "https://github.com/FGrosse",
"role": "Author"
},
{
"name": "All contributors",
"homepage": "https://github.com/FGrosse/PHPASN1/contributors"
}
],
"description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.",
"homepage": "https://github.com/FGrosse/PHPASN1",
"keywords": [
"DER",
"asn.1",
"asn1",
"ber",
"binary",
"decoding",
"encoding",
"x.509",
"x.690",
"x509",
"x690"
],
"support": {
"source": "https://github.com/1ma/PHPASN1/tree/v2.5.1"
},
"time": "2024-11-29T17:34:36+00:00"
}, },
{ {
"name": "uma/phpecc", "name": "uma/phpecc",
"version": "v0.1.3", "version": "v0.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/1ma/phpecc.git", "url": "https://github.com/1ma/phpecc.git",
"reference": "a83dfa5fd6801fcc029364a555cec584d351c481" "reference": "8952716a7378a829b9ce50535e913f6592664173"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/1ma/phpecc/zipball/a83dfa5fd6801fcc029364a555cec584d351c481", "url": "https://api.github.com/repos/1ma/phpecc/zipball/8952716a7378a829b9ce50535e913f6592664173",
"reference": "a83dfa5fd6801fcc029364a555cec584d351c481", "reference": "8952716a7378a829b9ce50535e913f6592664173",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-gmp": "*", "ext-gmp": "*",
"fgrosse/phpasn1": "^2.0", "php": "^8.0",
"php": "^8.0" "uma/phpasn1": "^2.5.1"
}, },
"replace": { "replace": {
"mdanter/ecc": "1.0.0" "mdanter/ecc": "1.0.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6.0||^8.0||^9.0", "phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^2.0", "squizlabs/php_codesniffer": "^2.0",
"symfony/yaml": "^2.6|^3.0" "symfony/yaml": "^6.4 || ^7.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -7611,9 +7500,9 @@
"secp256r1" "secp256r1"
], ],
"support": { "support": {
"source": "https://github.com/1ma/phpecc/tree/v0.1.3" "source": "https://github.com/1ma/phpecc/tree/v0.2.0"
}, },
"time": "2024-02-27T15:58:47+00:00" "time": "2024-11-29T17:59:36+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",

38
migrations/Version20241205135004.php

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241205135004 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// Remove duplicate entries
$this->addSql('DELETE FROM app_user
WHERE id NOT IN (
SELECT MIN(id)
FROM app_user
GROUP BY npub
);');
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E95FB8BABB ON app_user (npub)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_88BDF3E95FB8BABB');
}
}

4
src/Entity/Event.php

@ -6,11 +6,11 @@ class Event
{ {
private string $id; private string $id;
private int $kind = 0; private int $kind = 0;
private string $pubkey; private string $pubkey = '';
private string $content = ''; private string $content = '';
private int $created_at = 0; private int $created_at = 0;
private array $tags = []; private array $tags = [];
private string $sig; private string $sig = '';
public function getId(): string public function getId(): string
{ {

5
src/Entity/User.php

@ -2,6 +2,7 @@
namespace App\Entity; namespace App\Entity;
use App\Repository\UserEntityRepository;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
@ -9,7 +10,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** /**
* Entity storing local user representations * Entity storing local user representations
*/ */
#[ORM\Entity] #[ORM\Entity(repositoryClass: UserEntityRepository::class)]
#[ORM\Table(name: "app_user")] #[ORM\Table(name: "app_user")]
class User implements UserInterface class User implements UserInterface
{ {
@ -18,7 +19,7 @@ class User implements UserInterface
#[ORM\Column] #[ORM\Column]
private ?int $id = null; private ?int $id = null;
#[ORM\Column] #[ORM\Column(unique: true)]
private ?string $npub = null; private ?string $npub = null;
#[ORM\Column] #[ORM\Column]

25
src/Repository/UserEntityRepository.php

@ -0,0 +1,25 @@
<?php
namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
class UserEntityRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
public function findOrCreateByUniqueField(User $user): User
{
$entity = $this->findOneBy(['npub' => $user->getNpub()]);
if (!$entity) {
$this->_em->persist($user);
}
return $entity;
}
}

28
src/Security/NostrAuthenticator.php

@ -5,6 +5,7 @@ namespace App\Security;
use App\Entity\Event; use App\Entity\Event;
use App\Service\NostrClient; use App\Service\NostrClient;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Mdanter\Ecc\Crypto\Signature\SchnorrSignature;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@ -20,7 +21,7 @@ use Symfony\Component\Serializer\Serializer;
class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAuthenticatorInterface class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAuthenticatorInterface
{ {
public function __construct(private readonly NostrClient $nostrClient, private readonly EntityManagerInterface $entityManager) public function __construct(private readonly NostrClient $nostrClient)
{ {
} }
@ -42,27 +43,26 @@ class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAut
$eventStr = base64_decode(substr($authHeader, 6), true); $eventStr = base64_decode(substr($authHeader, 6), true);
$encoders = [new JsonEncoder()]; $encoders = [new JsonEncoder()];
$normalizers = [new ObjectNormalizer()]; $normalizers = [new ObjectNormalizer()];
$serializer = new Serializer($normalizers, $encoders); $serializer = new Serializer($normalizers, $encoders);
/** @var Event $event */ /** @var Event $event */
$event = $serializer->deserialize($eventStr, Event::class, 'json'); $event = $serializer->deserialize($eventStr, Event::class, 'json');
if (time() > $event->getCreatedAt() + 60) { if (time() > $event->getCreatedAt() + 60) {
throw new AuthenticationException('Expired'); throw new AuthenticationException('Expired');
} }
// TODO enable validity check after bug is fixed $validity = (new SchnorrSignature())->verify($event->getPubkey(), $event->getSig(), $event->getId());
// $validity = (new SchnorrSignature())->verify($event->getPubkey(), $event->getSig(), $event->getId());
// pretend all is well
$validity = true;
if (!$validity) { if (!$validity) {
throw new AuthenticationException('Invalid Authorization header'); throw new AuthenticationException('Invalid Authorization header');
} }
// default, in case this is a plain key with no metadata event
$user = new \App\Entity\User();
$user->setNpub($event->getPubkey());
try { try {
$user = $this->fetchUser($event->getPubkey()); $this->nostrClient->getMetadata([$event->getPubkey()]);
} catch (\Exception) { } catch (\Exception) {
// even if the user metadata not found, if sig is valid, login the pubkey // even if the user metadata not found, if sig is valid, login the pubkey
$user = new \App\Entity\User(); // TODO log?
$user->setNpub($event->getPubkey());
} }
return new SelfValidatingPassport( return new SelfValidatingPassport(
@ -80,16 +80,6 @@ class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAut
return null; return null;
} }
/**
*
* @throws \Exception
*/
private function fetchUser(string $publicKey): \App\Entity\User
{
$this->nostrClient->getMetadata([$publicKey]);
return $this->entityManager->getRepository(\App\Entity\User::class)->findOneBy(['npub' => $publicKey]);
}
public function isInteractive(): bool public function isInteractive(): bool
{ {
return true; return true;

7
src/Service/NostrClient.php

@ -6,6 +6,7 @@ use App\Entity\Article;
use App\Entity\User; use App\Entity\User;
use App\Enum\KindsEnum; use App\Enum\KindsEnum;
use App\Factory\ArticleFactory; use App\Factory\ArticleFactory;
use App\Repository\UserEntityRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use swentel\nostr\Filter\Filter; use swentel\nostr\Filter\Filter;
@ -20,6 +21,7 @@ use Symfony\Component\Serializer\SerializerInterface;
class NostrClient class NostrClient
{ {
public function __construct(private readonly EntityManagerInterface $entityManager, public function __construct(private readonly EntityManagerInterface $entityManager,
private readonly UserEntityRepository $userEntityRepository,
private readonly ArticleFactory $articleFactory, private readonly ArticleFactory $articleFactory,
private readonly SerializerInterface $serializer, private readonly SerializerInterface $serializer,
private readonly LoggerInterface $logger) private readonly LoggerInterface $logger)
@ -37,8 +39,7 @@ class NostrClient
$filter = new Filter(); $filter = new Filter();
$filter->setKinds([KindsEnum::LONGFORM]); $filter->setKinds([KindsEnum::LONGFORM]);
// TODO make filters configurable // TODO make filters configurable
$filter->setSince(strtotime('-1 year')); // $filter->setSince(strtotime('-1 day')); //
$filter->setUntil(strtotime('-11 months')); //
$requestMessage = new RequestMessage($subscriptionId, [$filter]); $requestMessage = new RequestMessage($subscriptionId, [$filter]);
// TODO make relays configurable // TODO make relays configurable
$relays = new RelaySet(); $relays = new RelaySet();
@ -115,7 +116,7 @@ class NostrClient
try { try {
$this->logger->info('Saving user', ['user' => $user]); $this->logger->info('Saving user', ['user' => $user]);
$this->entityManager->persist($user); $this->userEntityRepository->findOrCreateByUniqueField($user);
$this->entityManager->flush(); $this->entityManager->flush();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());

Loading…
Cancel
Save