diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 8964044..5f67ba1 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -2,30 +2,51 @@ security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
+ App\Entity\Profile:
+ algorithm: auto
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
- users_in_memory: { memory: null }
+ app_user_provider:
+ entity:
+ class: App\Entity\Profile
+ property: email
firewalls:
dev:
# Ensure dev tools and static assets are always allowed
pattern: ^/(_profiler|_wdt|assets|build)/
security: false
+
+ login:
+ pattern: ^/api/login_check
+ stateless: true
+ provider: app_user_provider
+ json_login:
+ check_path: /api/login_check
+ username_path: email
+ password_path: password
+ success_handler: lexik_jwt_authentication.handler.authentication_success
+ failure_handler: lexik_jwt_authentication.handler.authentication_failure
+
+ api:
+ pattern: ^/api
+ stateless: true
+ jwt: ~
+
main:
lazy: true
- provider: users_in_memory
-
- # Activate different ways to authenticate:
- # https://symfony.com/doc/current/security.html#the-firewall
-
- # https://symfony.com/doc/current/security/impersonating_user.html
- # switch_user: true
+ provider: app_user_provider
# Note: Only the *first* matching rule is applied
access_control:
- # - { path: ^/admin, roles: ROLE_ADMIN }
- # - { path: ^/profile, roles: ROLE_USER }
+ - { path: ^/api/login, roles: PUBLIC_ACCESS }
+ - { path: ^/api/docs, roles: PUBLIC_ACCESS }
+ - { path: ^/api/test, roles: PUBLIC_ACCESS }
+ - { path: ^/docs, roles: PUBLIC_ACCESS }
+ - { path: ^/contexts, roles: PUBLIC_ACCESS }
+ - { path: ^/\.well-known, roles: PUBLIC_ACCESS }
+ - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
when@test:
security:
diff --git a/config/routes.yaml b/config/routes.yaml
index cef258c..58a67fe 100644
--- a/config/routes.yaml
+++ b/config/routes.yaml
@@ -7,5 +7,8 @@
# To list all registered routes, run the following command:
# bin/console debug:router
+api_login_check:
+ path: /api/login_check
+
controllers:
resource: routing.controllers
diff --git a/config/routes/api_platform.yaml b/config/routes/api_platform.yaml
index 14f6e99..38f11cb 100644
--- a/config/routes/api_platform.yaml
+++ b/config/routes/api_platform.yaml
@@ -1,4 +1,4 @@
api_platform:
resource: .
type: api_platform
- prefix: /
+ prefix: /api
diff --git a/config/routes/routing.controllers.yaml b/config/routes/routing.controllers.yaml
new file mode 100644
index 0000000..edf9c88
--- /dev/null
+++ b/config/routes/routing.controllers.yaml
@@ -0,0 +1,5 @@
+controllers:
+ resource:
+ path: ../../src/Controller/
+ namespace: App\Controller
+ type: attribute
diff --git a/public/.htaccess b/public/.htaccess
new file mode 100644
index 0000000..74a7a75
--- /dev/null
+++ b/public/.htaccess
@@ -0,0 +1,70 @@
+# Use the front controller as index file. It serves as a fallback solution when
+# every other rewrite/redirect fails (e.g. in an aliased environment without
+# mod_rewrite). Additionally, this reduces the matching process for the
+# start page (path "/") because otherwise Apache will apply the rewriting rules
+# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
+DirectoryIndex index.php
+
+# By default, Apache does not evaluate symbolic links if you did not enable this
+# feature in your server configuration. Uncomment the following line if you
+# install assets as symlinks or if you experience problems related to symlinks
+# when compiling LESS/Sass/CoffeeScript assets.
+# Options +FollowSymlinks
+
+# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
+# to the front controller "/index.php" but be rewritten to "/index.php/index".
+
+ Options -MultiViews
+
+
+
+ # This Option needs to be enabled for RewriteRule, otherwise it will show an error like
+ # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden'
+ Options +FollowSymlinks
+
+ RewriteEngine On
+
+ # Determine the RewriteBase automatically and set it as environment variable.
+ # If you are using Apache aliases to do mass virtual hosting or installed the
+ # project in a subdirectory, the base path will be prepended to allow proper
+ # resolution of the index.php file and to redirect to the correct URI. It will
+ # work in environments without path prefix as well, providing a safe, one-size
+ # fits all solution. But as you do not need it in this case, you can comment
+ # the following 2 lines to eliminate the overhead.
+ RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
+ RewriteRule .* - [E=BASE:%1]
+
+ # Sets the HTTP_AUTHORIZATION header removed by Apache
+ RewriteCond %{HTTP:Authorization} .+
+ RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
+
+ # Redirect to URI without front controller to prevent duplicate content
+ # (with and without `/index.php`). Only do this redirect on the initial
+ # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
+ # endless redirect loop (request -> rewrite to front controller ->
+ # redirect to URI without front controller -> request -> ...).
+ # So in case you get a "too many redirects" error or you always get redirected
+ # to the start page because your Apache does not expose the REDIRECT_STATUS
+ # environment variable, you have 2 choices:
+ # - disable this feature by commenting the following 2 lines or
+ # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
+ # following RewriteCond (best solution)
+ RewriteCond %{ENV:REDIRECT_STATUS} =""
+ RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
+
+ # If the requested filename exists, simply serve it.
+ # We only want to let Apache serve files and not directories.
+ # Rewrite all other queries to the front controller.
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ %{ENV:BASE}/index.php [L]
+
+
+
+
+ # When mod_rewrite is not available, we instruct a temporary redirect of
+ # the start page to the front controller explicitly so that the website
+ # and the generated links can still be used.
+ RedirectMatch 307 ^/$ /index.php/
+ # RedirectTemp cannot be used instead
+
+
diff --git a/src/Controller/TestController.php b/src/Controller/TestController.php
new file mode 100644
index 0000000..956ab2a
--- /dev/null
+++ b/src/Controller/TestController.php
@@ -0,0 +1,18 @@
+json(['status' => 'ok', 'message' => 'Test endpoint works!']);
+ }
+}