Skip to content

Commit

Permalink
remove last commit : remettre les /api pour éviter les conflits d'url
Browse files Browse the repository at this point in the history
  • Loading branch information
moreaud committed Nov 18, 2024
1 parent 06fcb91 commit 9c044ae
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion config/packages/nelmio_cors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ nelmio_cors:
expose_headers: ['Link']
max_age: 3600
paths:
'^/':
'^/api':
allow_origin: ['*']
allow_headers: ['X-Custom-Auth', 'Authorization', 'Content-Type']
allow_methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
'^/': null
12 changes: 6 additions & 6 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ security:
security: false

api_token_refresh:
pattern: ^/token/refresh$
pattern: ^/api/token/refresh$
stateless: true
# user_checker: user_checker_service_id
refresh_jwt: ~

api_login:
pattern: ^/login$
pattern: ^/api/login$
stateless: true
json_login:
check_path: /login # or api_login_check as defined in config/routes.yaml
check_path: /api/login # or api_login_check as defined in config/routes.yaml
# success_handler: lexik_jwt_authentication.handler.authentication_success
success_handler: app.lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
# failure_handler: app.lexik_jwt_authentication.handler.authentication_failure
provider: app_user_provider
# refresh_jwt:
# check_path: /token/refresh
# check_path: /api/token/refresh

api:
pattern: ^/api
Expand Down Expand Up @@ -68,8 +68,8 @@ security:
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/login$, roles: PUBLIC_ACCESS }
- { path: ^/token/refresh$, roles: PUBLIC_ACCESS }
- { path: ^/api/login$, roles: PUBLIC_ACCESS }
- { path: ^/api/token/refresh$, roles: PUBLIC_ACCESS }
- { path: ^/api, methods: [GET], roles: PUBLIC_ACCESS}
- { path: ^/api, methods: [POST, PUT, PATCH, DELETE], roles: IS_AUTHENTICATED_FULLY}
- { path: ^/, roles: PUBLIC_ACCESS }
Expand Down
2 changes: 1 addition & 1 deletion config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ controllers:
type: attribute

gesdinet_jwt_refresh_token:
path: /token/refresh
path: /api/token/refresh
controller: gesdinet.jwtrefreshtoken::refresh
2 changes: 1 addition & 1 deletion config/routes/gesdinet_jwt_refresh_token.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gesdinet_jwt_refresh_token:
path: /token/refresh
path: /api/token/refresh
10 changes: 5 additions & 5 deletions src/Controller/Api/ApiForetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(ForetRepository $foretRepository)
$this->foretRepository = $foretRepository;
}

#[Route('/forets', name: 'api_foret_get', methods:["GET"])]
#[Route('/api/forets', name: 'api_foret_get', methods:["GET"])]
public function get(SerializerInterface $serializer): Response
{
/** @var User $user */
Expand All @@ -37,7 +37,7 @@ public function get(SerializerInterface $serializer): Response
));
}

#[Route('/forets/{id}', name: 'api_foret_getone', methods:["GET"])]
#[Route('/api/forets/{id}', name: 'api_foret_getone', methods:["GET"])]
public function getOne(int $id, SerializerInterface $serializer): Response
{
/** @var User $user */
Expand All @@ -61,7 +61,7 @@ public function getOne(int $id, SerializerInterface $serializer): Response
));
}

#[Route('/forets', name: 'api_foret_post', methods:["POST"])]
#[Route('/api/forets', name: 'api_foret_post', methods:["POST"])]
public function post(Request $request, SerializerInterface $serializer): Response
{
$data = json_decode($request->getContent());
Expand All @@ -81,7 +81,7 @@ public function post(Request $request, SerializerInterface $serializer): Respons
));
}

#[Route('/forets/{id}', name: 'api_foret_puth', methods:["PUT"])]
#[Route('/api/forets/{id}', name: 'api_foret_puth', methods:["PUT"])]
public function put(int $id, Request $request, SerializerInterface $serializer): Response
{
/** @var Foret $foret */
Expand Down Expand Up @@ -110,7 +110,7 @@ public function put(int $id, Request $request, SerializerInterface $serializer):
));
}

#[Route('/forets/{id}', name: 'api_foret_delete', methods:["DELETE"])]
#[Route('/api/forets/{id}', name: 'api_foret_delete', methods:["DELETE"])]
public function delete(int $id): Response
{
$foret = $this->foretRepository->find($id);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Api/ApiMeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(UserRepository $userRepository)
$this->userRepository = $userRepository;
}

#[Route('/me', name: 'app_api_me', methods:["GET"])]
#[Route('/api/me', name: 'app_api_me', methods:["GET"])]
public function index(SerializerInterface $serializer): Response
{
/** @var User $user */
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(RefreshTokenRepository $refreshTokenRepository)
$this->refreshTokenRepository = $refreshTokenRepository;
}

#[Route(path: '/login-temporaire', name: 'app_login')]
#[Route(path: '/login', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils): Response
{
// get the login error if there is one
Expand All @@ -36,7 +36,7 @@ public function login(AuthenticationUtils $authenticationUtils): Response
]);
}

#[Route(path: '/login', name: 'api_login')]
#[Route(path: '/api/login', name: 'api_login')]
public function apiLogin(): Response
{
return new Response('ok');
Expand Down

0 comments on commit 9c044ae

Please sign in to comment.