Compare commits

..

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

  1. 38
      .env.tpl
  2. 4
      assets/app.js
  3. 2
      assets/bootstrap.js
  4. 2
      assets/controllers/hello_controller.js
  5. 3
      assets/styles/app.css
  6. 42
      bin/console
  7. 32
      composer.json
  8. 3418
      composer.lock
  9. 2
      config/bundles.php
  10. 3
      config/packages/reset_password.yaml
  11. 25
      config/packages/webpack_encore.yaml
  12. 12571
      package-lock.json
  13. 28
      package.json
  14. 39
      src/Controller/ResetPasswordController.php
  15. 53
      src/Controller/SfyCASLoginController.php
  16. 60
      src/Controller/SfyCASServiceValidator.php
  17. 20
      src/Repository/ResetPasswordRequestRepository.php
  18. 15
      symfony.lock
  19. 103
      templates/base.html.twig
  20. 6
      templates/reset_password/request.html.twig
  21. 5
      templates/sfy_cas_validate/error.html.twig
  22. 5
      templates/sfy_cas_validate/sucess.html.twig
  23. 13
      webpack.config.js
  24. 5754
      yarn.lock

@ -1,38 +0,0 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=***************************
###< symfony/framework-bundle ###
###> symfony/mailer ###
MAILER_DSN=smtp://kubuntu:25?verify_peer=false&verify_peer_name=false
###< symfony/mailer ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
DATABASE_URL="mysql://sfy:*********@127.0.0.1:3306/sfycas?serverVersion=5.7"
#DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###
###> symfony/google-mailer ###
# Gmail SHOULD NOT be used on production, use it in development only.
# MAILER_DSN=gmail://USERNAME:PASSWORD@default
###< symfony/google-mailer ###

@ -5,13 +5,11 @@
* (and its CSS file) in your base layout (base.html.twig). * (and its CSS file) in your base layout (base.html.twig).
*/ */
// any CSS you import will output into a single css file (app.css in this case) // any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss'; import './styles/app.scss';
import 'bootstrap';
import bsCustomFileInput from 'bs-custom-file-input';
// start the Stimulus application // start the Stimulus application
import './bootstrap'; import './bootstrap';
import bsCustomFileInput from "bs-custom-file-input";
bsCustomFileInput.init(); bsCustomFileInput.init();

@ -4,7 +4,7 @@ import { startStimulusApp } from '@symfony/stimulus-bridge';
export const app = startStimulusApp(require.context( export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers', '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true, true,
/\.[jt]sx?$/ /\.(j|t)sx?$/
)); ));
// register any custom, 3rd party controllers here // register any custom, 3rd party controllers here

@ -1,4 +1,4 @@
import { Controller } from '@hotwired/stimulus'; import { Controller } from 'stimulus';
/* /*
* This is an example Stimulus controller! * This is an example Stimulus controller!

@ -1,3 +0,0 @@
body {
background-color: lightgray;
}

@ -1,42 +0,0 @@
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
}
set_time_limit(0);
require dirname(__DIR__).'/vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);

@ -12,16 +12,16 @@
"doctrine/orm": "^2.8", "doctrine/orm": "^2.8",
"easycorp/easyadmin-bundle": "^2.0", "easycorp/easyadmin-bundle": "^2.0",
"sensio/framework-extra-bundle": "^6.1", "sensio/framework-extra-bundle": "^6.1",
"symfony/console": "5.4.*", "symfony/console": "5.0.*",
"symfony/dotenv": "5.4.*", "symfony/dotenv": "5.0.*",
"symfony/flex": "^1.3.1", "symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.4.*", "symfony/framework-bundle": "5.0.*",
"symfony/mailer": "5.4.*", "symfony/mailer": "5.0.*",
"symfony/proxy-manager-bridge": "5.4.*", "symfony/proxy-manager-bridge": "5.0.*",
"symfony/security-bundle": "5.4.*", "symfony/security-bundle": "5.0.*",
"symfony/webpack-encore-bundle": "^1.17", "symfony/webpack-encore-bundle": "^1.12",
"symfony/yaml": "5.4.*", "symfony/yaml": "5.0.*",
"symfonycasts/reset-password-bundle": "^1.17" "symfonycasts/reset-password-bundle": "^1.9"
}, },
"config": { "config": {
"preferred-install": { "preferred-install": {
@ -70,17 +70,17 @@
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": false, "allow-contrib": false,
"require": "5.4.*" "require": "5.0.*"
} }
}, },
"require-dev": { "require-dev": {
"symfony/debug-bundle": "^5.4", "symfony/debug-bundle": "^5.0",
"symfony/google-mailer": "5.4.*", "symfony/google-mailer": "5.0.*",
"symfony/maker-bundle": "^1.31", "symfony/maker-bundle": "^1.31",
"symfony/monolog-bundle": "^3.0", "symfony/monolog-bundle": "^3.0",
"symfony/stopwatch": "^5.4", "symfony/stopwatch": "^5.0",
"symfony/twig-bundle": "^5.4", "symfony/twig-bundle": "^5.0",
"symfony/var-dumper": "^5.4", "symfony/var-dumper": "^5.0",
"symfony/web-profiler-bundle": "^5.4" "symfony/web-profiler-bundle": "^5.0"
} }
} }

3418
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -12,6 +12,6 @@ return [
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true], EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true], SymfonyCasts\Bundle\ResetPassword\SymfonyCastsResetPasswordBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
]; ];

@ -1,2 +1,5 @@
symfonycasts_reset_password: symfonycasts_reset_password:
request_password_repository: App\Repository\ResetPasswordRequestRepository request_password_repository: App\Repository\ResetPasswordRequestRepository
lifetime: 3600
throttle_limit: 5
enable_garbage_collection: true

@ -7,12 +7,7 @@ webpack_encore:
# Set attributes that will be rendered on all script and link tags # Set attributes that will be rendered on all script and link tags
script_attributes: script_attributes:
defer: true defer: true
# Uncomment (also under link_attributes) if using Turbo Drive
# https://turbo.hotwired.dev/handbook/drive#reloading-when-assets-change
# 'data-turbo-track': reload
# link_attributes: # link_attributes:
# Uncomment if using Turbo Drive
# 'data-turbo-track': reload
# If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
# crossorigin: 'anonymous' # crossorigin: 'anonymous'
@ -25,21 +20,11 @@ webpack_encore:
# If you have multiple builds: # If you have multiple builds:
# builds: # builds:
# frontend: '%kernel.project_dir%/public/frontend/build' # pass "frontend" as the 3rg arg to the Twig functions
# pass the build name as the 3rd argument to the Twig functions
# {{ encore_entry_script_tags('entry1', null, 'frontend') }} # {{ encore_entry_script_tags('entry1', null, 'frontend') }}
framework: # frontend: '%kernel.project_dir%/public/frontend/build'
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
#when@prod:
# webpack_encore:
# # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
# # Available in version 1.2
# cache: true
#when@test: # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
# webpack_encore: # Put in config/packages/prod/webpack_encore.yaml
# strict_mode: false # cache: true

12571
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,20 +1,15 @@
{ {
"devDependencies": { "devDependencies": {
"@babel/core": "^7.17.0", "@symfony/stimulus-bridge": "^2.0.0",
"@babel/preset-env": "^7.16.0", "@symfony/webpack-encore": "^1.0.0",
"@hotwired/stimulus": "^3.0.0", "bootstrap": "^5.0.2",
"@popperjs/core": "^2.11.8",
"@symfony/stimulus-bridge": "^3.2.0",
"@symfony/webpack-encore": "^4.0.0",
"bootstrap": "^5.3.0",
"bs-custom-file-input": "^1.3.4", "bs-custom-file-input": "^1.3.4",
"core-js": "^3.23.0", "core-js": "^3.0.0",
"regenerator-runtime": "^0.13.9", "jquery": "^3.6.0",
"sass": "^1.62.1", "popper.js": "^1.16.1",
"sass-loader": "^13.3.1", "regenerator-runtime": "^0.13.2",
"webpack": "^5.74.0", "stimulus": "^2.0.0",
"webpack-cli": "^4.10.0", "webpack-notifier": "^1.6.0"
"webpack-notifier": "^1.15.0"
}, },
"license": "UNLICENSED", "license": "UNLICENSED",
"private": true, "private": true,
@ -23,5 +18,10 @@
"dev": "encore dev", "dev": "encore dev",
"watch": "encore dev --watch", "watch": "encore dev --watch",
"build": "encore production --progress" "build": "encore production --progress"
},
"dependencies": {
"node-sass": "4",
"sass-loader": "10.0.0",
"yarn": "^1.22.10"
} }
} }

@ -5,7 +5,6 @@ namespace App\Controller;
use App\Entity\User; use App\Entity\User;
use App\Form\ChangePasswordFormType; use App\Form\ChangePasswordFormType;
use App\Form\ResetPasswordRequestFormType; use App\Form\ResetPasswordRequestFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bridge\Twig\Mime\TemplatedEmail; use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
@ -13,9 +12,8 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Address;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait; use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait;
use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface; use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface;
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface; use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface;
@ -27,13 +25,11 @@ class ResetPasswordController extends AbstractController
{ {
use ResetPasswordControllerTrait; use ResetPasswordControllerTrait;
private ResetPasswordHelperInterface $resetPasswordHelper; private $resetPasswordHelper;
private EntityManagerInterface $entityManager;
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper, EntityManagerInterface $entityManager) public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
{ {
$this->resetPasswordHelper = $resetPasswordHelper; $this->resetPasswordHelper = $resetPasswordHelper;
$this->entityManager = $entityManager;
} }
/** /**
@ -41,7 +37,7 @@ class ResetPasswordController extends AbstractController
* *
* @Route("", name="app_forgot_password_request") * @Route("", name="app_forgot_password_request")
*/ */
public function request(Request $request, MailerInterface $mailer, TranslatorInterface $translator): Response public function request(Request $request, MailerInterface $mailer): Response
{ {
$form = $this->createForm(ResetPasswordRequestFormType::class); $form = $this->createForm(ResetPasswordRequestFormType::class);
$form->handleRequest($request); $form->handleRequest($request);
@ -49,8 +45,7 @@ class ResetPasswordController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
return $this->processSendingPasswordResetEmail( return $this->processSendingPasswordResetEmail(
$form->get('email')->getData(), $form->get('email')->getData(),
$mailer, $mailer
$translator
); );
} }
@ -82,7 +77,7 @@ class ResetPasswordController extends AbstractController
* *
* @Route("/reset/{token}", name="app_reset_password") * @Route("/reset/{token}", name="app_reset_password")
*/ */
public function reset(Request $request, UserPasswordHasherInterface $userPasswordHasher, TranslatorInterface $translator, string $token = null): Response public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder, string $token = null): Response
{ {
if ($token) { if ($token) {
// We store the token in session and remove it from the URL, to avoid the URL being // We store the token in session and remove it from the URL, to avoid the URL being
@ -101,9 +96,8 @@ class ResetPasswordController extends AbstractController
$user = $this->resetPasswordHelper->validateTokenAndFetchUser($token); $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
} catch (ResetPasswordExceptionInterface $e) { } catch (ResetPasswordExceptionInterface $e) {
$this->addFlash('reset_password_error', sprintf( $this->addFlash('reset_password_error', sprintf(
'%s - %s', 'There was a problem validating your reset request - %s',
$translator->trans(ResetPasswordExceptionInterface::MESSAGE_PROBLEM_VALIDATE, [], 'ResetPasswordBundle'), $e->getReason()
$translator->trans($e->getReason(), [], 'ResetPasswordBundle')
)); ));
return $this->redirectToRoute('app_forgot_password_request'); return $this->redirectToRoute('app_forgot_password_request');
@ -117,14 +111,14 @@ class ResetPasswordController extends AbstractController
// A password reset token should be used only once, remove it. // A password reset token should be used only once, remove it.
$this->resetPasswordHelper->removeResetRequest($token); $this->resetPasswordHelper->removeResetRequest($token);
// Encode(hash) the plain password, and set it. // Encode the plain password, and set it.
$encodedPassword = $userPasswordHasher->hashPassword( $encodedPassword = $passwordEncoder->encodePassword(
$user, $user,
$form->get('plainPassword')->getData() $form->get('plainPassword')->getData()
); );
$user->setPassword($encodedPassword); $user->setPassword($encodedPassword);
$this->entityManager->flush(); $this->getDoctrine()->getManager()->flush();
// The session is cleaned up after the password has been changed. // The session is cleaned up after the password has been changed.
$this->cleanSessionAfterReset(); $this->cleanSessionAfterReset();
@ -137,9 +131,9 @@ class ResetPasswordController extends AbstractController
]); ]);
} }
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer, TranslatorInterface $translator): RedirectResponse private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse
{ {
$user = $this->entityManager->getRepository(User::class)->findOneBy([ $user = $this->getDoctrine()->getRepository(User::class)->findOneBy([
'email' => $emailFormData, 'email' => $emailFormData,
]); ]);
@ -156,16 +150,15 @@ class ResetPasswordController extends AbstractController
// Caution: This may reveal if a user is registered or not. // Caution: This may reveal if a user is registered or not.
// //
// $this->addFlash('reset_password_error', sprintf( // $this->addFlash('reset_password_error', sprintf(
// '%s - %s', // 'There was a problem handling your password reset request - %s',
// $translator->trans(ResetPasswordExceptionInterface::MESSAGE_PROBLEM_HANDLE, [], 'ResetPasswordBundle'), // $e->getReason()
// $translator->trans($e->getReason(), [], 'ResetPasswordBundle')
// )); // ));
return $this->redirectToRoute('app_check_email'); return $this->redirectToRoute('app_check_email');
} }
$email = (new TemplatedEmail()) $email = (new TemplatedEmail())
->from(new Address('mailer@sfycas.local', '"Sfycas mail bot"')) ->from(new Address('k.jouini@tyr.local', 'SfyCAS Mail Bot'))
->to($user->getEmail()) ->to($user->getEmail())
->subject('Your password reset request') ->subject('Your password reset request')
->htmlTemplate('reset_password/email.html.twig') ->htmlTemplate('reset_password/email.html.twig')

@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -49,68 +48,32 @@ class SfyCASLoginController extends AbstractController
print_r($request->query->get('service')); print_r($request->query->get('service'));
echo '<br>'; echo '<br>';
*/ */
$user = $this->getUser();
$_casSession=$sfyCASSessionRepository->findBy(['user' => $this->getUser()]); $_casSession=$sfyCASSessionRepository->findBy(['user' => $this->getUser()]);
if(is_array($_casSession) && count($_casSession) > 0) { if(is_array($_casSession) && count($_casSession) > 0) {
$casSession=$_casSession[0]; $casSession=$_casSession[0];
$ticket=$casSession->getTicket(); $logger->info('SFYCAS Session : ' . $casSession->getTicket());
$logger->info('SFYCAS ticket ' . $casSession->getTicket() . ' found for user : ' . $user);
} else { } else {
$logger->info('SFYCAS Session : create new cas session');
$casSession=new SfyCASSession(); $casSession=new SfyCASSession();
$ticket=$ticketGenerator->getTicket();
$casSession->setLogin($user->getUsername());
$casSession->setUser($user);
$casSession->setTicket('ST-' . $ticket);
} }
$chemin=$request->getBasePath();
//$logger->info('SFYCAS login base url : ' . $request);
$service=$request->query->get('service'); $service=$request->query->get('service');
//$user=$this->getUser(); $user=$this->getUser();
//echo $user->getUsername(); //echo $user->getUsername();
//$ticket=$ticketGenerator->getTicket(); $ticket=$ticketGenerator->getTicket();
//$casSession->setLogin($user->getUsername()); $casSession->setLogin($user->getUsername());
//$casSession->setUser($user); $casSession->setUser($user);
//$casSession->setTicket('ST-' . $ticket); $casSession->setTicket('ST-' . $ticket);
$entityManager = $this->getDoctrine()->getManager(); $entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($casSession); $entityManager->persist($casSession);
$entityManager->flush(); $entityManager->flush();
//$response = new RedirectResponse($service. '?ticket=ST-ABFDABFE'); //$response = new RedirectResponse($service. '?ticket=ST-ABFDABFE');
$response = new RedirectResponse($service. '&ticket=ST-' . $ticket);
$attributes = parse_url($service);
//$params = $attributes['query'];
if(isset($attributes['query'])) {
$responseUrl = $service. '&ticket=ST-'.$ticket;
} else {
$responseUrl = $service. '?ticket=ST-'.$ticket;
}
//$response = new RedirectResponse($service. '?ticket=ST-' . $ticket);
$response = new RedirectResponse($responseUrl);
/*$response->headers->set('Set-Cookie',
Cookie::create(
'sfy_cas_session',
$casSession->getTicket(),
time() + 60 * 60 * 24 * 30,
'/',
null,
false,
true,
false,
Cookie::SAMESITE_LAX
)
);
*/
$response->headers->setCookie(Cookie::create('CASTGC', 'ST-' . $ticket)); $response->headers->setCookie(Cookie::create('CASTGC', 'ST-' . $ticket));
$logger->info('SFYCAS login user : ' . $user . 'ticket ' . $ticket . ' service : ' . $service); $logger->info('SFYCAS login user : ' . $user . ' service : ' . $service);
return $response; return $response;
//return $this->redirect($service. '?ticket=ST-ABFDABFE'); //return $this->redirect($service. '?ticket=ST-ABFDABFE');

@ -19,64 +19,18 @@ class SfyCASServiceValidator extends AbstractController {
public function validate(Request $request, LoggerInterface $logger): Response public function validate(Request $request, LoggerInterface $logger): Response
{ {
$logger->warning('SFYCAS validate ' . $request->query->get('ticket')); $logger->warning('SFYCAS validate ' . $request->query->get('ticket'));
$ticket = $request->query->get('ticket'); $ticket=$request->query->get('ticket');
$logger->info('SFYCAS validate : looking session for ticket ' . $ticket);
$casSession = $this->getDoctrine()->getRepository(SfyCASSession::class) $casSession = $this->getDoctrine()->getRepository(SfyCASSession::class)
->findOneBy(['ticket' => $ticket]); ->findOneBy(['ticket' => $ticket]);
$logger->info('SFYCAS validate found session ' . $casSession->getLogin());
if ($casSession) { return $this->render('sfy_cas_login/cas_validate.html.twig', [
$logger->info('SFYCAS validate found session ' . $casSession->getLogin() . ' ticket ' . $casSession->getTicket()); 'controller_name' => 'SfyCASServiceValidator',
'login' => $casSession->getLogin(),
return $this->render('sfy_cas_login/cas_validate.html.twig', [ 'ticket' => $casSession->getTicket(),
'controller_name' => 'SfyCASServiceValidator', ]);
'login' => $casSession->getLogin(),
'ticket' => $casSession->getTicket(),
]);
} else {
$logger->info('SFYCAS no session found for ticket ' . $ticket);
return $this->render('sfy_cas_validate/error.html.twig', [
'controller_name' => 'SfyCASServiceValidator',
'message' => 'ticket not found',
]);
}
} }
/**
* @Route("/cas/p3/serviceValidate", defaults={"_format"="xml"}, name="app_cas_p3_validate")
*/
public function p3Validate(Request $request, LoggerInterface $logger): Response
{
$logger->warning('SFYCAS p3 validate '. $request->query->get('ticket'));
//$response = $this->forward('App\Controller\SfyCASServiceValidator::validate', ['request' => $request]);
//return $response;
$ticket = $request->query->get('ticket');
if(substr($ticket, 0, strlen('ST-ST')) === 'ST-ST'){
$ticket = substr($ticket, 3);
}
$logger->info('SFYCAS p3 validate : looking CAS session for ticket ' . $ticket);
$casSession = $this->getDoctrine()->getRepository(SfyCASSession::class)
->findOneBy(['ticket' => $ticket]);
if ($casSession) {
$logger->info('SFYCAS v3 validate found session ' . $casSession->getLogin() . ' ticket ' . $casSession->getTicket());
return $this->render('sfy_cas_login/cas_validate.html.twig', [
'controller_name' => 'SfyCASServiceValidator',
'login' => $casSession->getLogin(),
'ticket' => $casSession->getTicket(),
]);
} else {
$logger->info('SFYCAS no session found for ticket ' . $ticket);
return $this->render('sfy_cas_validate/error.html.twig', [
'controller_name' => 'SfyCASServiceValidator',
'message' => 'ticket not found',
]);
}
}
} }

@ -10,8 +10,6 @@ use SymfonyCasts\Bundle\ResetPassword\Persistence\Repository\ResetPasswordReques
use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface; use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface;
/** /**
* @extends ServiceEntityRepository<ResetPasswordRequest>
*
* @method ResetPasswordRequest|null find($id, $lockMode = null, $lockVersion = null) * @method ResetPasswordRequest|null find($id, $lockMode = null, $lockVersion = null)
* @method ResetPasswordRequest|null findOneBy(array $criteria, array $orderBy = null) * @method ResetPasswordRequest|null findOneBy(array $criteria, array $orderBy = null)
* @method ResetPasswordRequest[] findAll() * @method ResetPasswordRequest[] findAll()
@ -26,24 +24,6 @@ class ResetPasswordRequestRepository extends ServiceEntityRepository implements
parent::__construct($registry, ResetPasswordRequest::class); parent::__construct($registry, ResetPasswordRequest::class);
} }
public function add(ResetPasswordRequest $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(ResetPasswordRequest $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function createResetPasswordRequest(object $user, \DateTimeInterface $expiresAt, string $selector, string $hashedToken): ResetPasswordRequestInterface public function createResetPasswordRequest(object $user, \DateTimeInterface $expiresAt, string $selector, string $hashedToken): ResetPasswordRequestInterface
{ {
return new ResetPasswordRequest($user, $expiresAt, $selector, $hashedToken); return new ResetPasswordRequest($user, $expiresAt, $selector, $hashedToken);

@ -456,12 +456,12 @@
] ]
}, },
"symfony/webpack-encore-bundle": { "symfony/webpack-encore-bundle": {
"version": "1.17", "version": "1.9",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes", "repo": "github.com/symfony/recipes",
"branch": "main", "branch": "master",
"version": "1.10", "version": "1.9",
"ref": "eff2e505d4557c967b6710fe06bd947ba555cae5" "ref": "12e0ad8155c23b9f9290e8c49215d4ec921cdf71"
}, },
"files": [ "files": [
"assets/app.js", "assets/app.js",
@ -469,6 +469,9 @@
"assets/controllers.json", "assets/controllers.json",
"assets/controllers/hello_controller.js", "assets/controllers/hello_controller.js",
"assets/styles/app.css", "assets/styles/app.css",
"config/packages/assets.yaml",
"config/packages/prod/webpack_encore.yaml",
"config/packages/test/webpack_encore.yaml",
"config/packages/webpack_encore.yaml", "config/packages/webpack_encore.yaml",
"package.json", "package.json",
"webpack.config.js" "webpack.config.js"
@ -478,10 +481,10 @@
"version": "v5.0.11" "version": "v5.0.11"
}, },
"symfonycasts/reset-password-bundle": { "symfonycasts/reset-password-bundle": {
"version": "1.17", "version": "1.0",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes", "repo": "github.com/symfony/recipes",
"branch": "main", "branch": "master",
"version": "1.0", "version": "1.0",
"ref": "97c1627c0384534997ae1047b93be517ca16de43" "ref": "97c1627c0384534997ae1047b93be517ca16de43"
}, },

@ -1,86 +1,19 @@
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>{% block title %}Welcome!{% endblock %}</title>
{# Run `composer require symfony/webpack-encore-bundle`
<title>{% block title %}Welcome!{% endblock %}</title> and uncomment the following Encore helpers to start using Symfony UX #}
{% block stylesheets %}
{% block stylesheets %} {{ encore_entry_link_tags('app') }}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,500,500i,600,600i&display=swap" rel="stylesheet" /> {% endblock %}
{{ encore_entry_link_tags('app') }}
{% endblock %} {% block javascripts %}
</head> {{ encore_entry_script_tags('app') }}
<body> {% endblock %}
<header class="header"> </head>
<h1 class="sr-only"> <body>
Symfony sandbox {% block body %}{% endblock %}
</h1> </body>
<nav class="navbar navbar-expand-xl navbar-light bg-light">
<div class="container mt-4 mb-3">
<a class="navbar-brand mr-4 pr-2" href="{{ path('app_home') }}">
&#128217; Home
</a>
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#header-menu" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Show/Hide navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="header-menu">
<ul class="navbar-nav ml-auto">
<li class="nav-item mr-3">
<a class="nav-link" href="{{ path('app_home') }}">
Import
</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse" id="header-menu">
<ul class="navbar-nav ml-auto">
<li class="nav-item mr-3">
<a class="nav-link" href="">
Export
</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse" id="header-menu">
<ul class="navbar-nav ml-auto">
<li class="nav-item mr-3">
<a class="nav-link" href="{{ path('app_home') }}">
Admin
</a>
</li>
</ul>
</div>
</div>
</nav>
<nav class="bg-light border-bottom">
<div class="container">
{# render_esi(path('conference_header')) #}
</div>
</nav>
</header>
<main role="main" class="container mt-5">
{% block body %}{% endblock %}
</main>
<footer class="mt-7 px-3 py-5 text-center text-muted">
<p>
Symfony sandbox
</p>
<p>
<a href="#" class="text-white">Back to top</a>
</p>
</footer>
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</body>
</html> </html>

@ -3,8 +3,8 @@
{% block title %}Reset your password{% endblock %} {% block title %}Reset your password{% endblock %}
{% block body %} {% block body %}
{% for flash_error in app.flashes('reset_password_error') %} {% for flashError in app.flashes('reset_password_error') %}
<div class="alert alert-danger" role="alert">{{ flash_error }}</div> <div class="alert alert-danger" role="alert">{{ flashError }}</div>
{% endfor %} {% endfor %}
<h1>Reset your password</h1> <h1>Reset your password</h1>
@ -12,7 +12,7 @@
{{ form_row(requestForm.email) }} {{ form_row(requestForm.email) }}
<div> <div>
<small> <small>
Enter your email address and we will send you a Enter your email address and we we will send you a
link to reset your password. link to reset your password.
</small> </small>
</div> </div>

@ -1,5 +0,0 @@
<cas:serviceResponse xmlns:cas="http://www.yale.edu/tp/cas">
<cas:authenticationFailure code="INVALID_TICKET">
{{ message}}
</cas:authenticationFailure>
</cas:serviceResponse>

@ -1,5 +0,0 @@
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>{{ login }}</cas:user>
</cas:authenticationSuccess>
</cas:serviceResponse>

@ -11,7 +11,7 @@ Encore
.setOutputPath('public/build/') .setOutputPath('public/build/')
// public path used by the web server to access the output path // public path used by the web server to access the output path
.setPublicPath('/build') .setPublicPath('/build')
// only needed for CDN's or subdirectory deploy // only needed for CDN's or sub-directory deploy
//.setManifestKeyPrefix('build/') //.setManifestKeyPrefix('build/')
/* /*
@ -45,15 +45,14 @@ Encore
// enables hashed filenames (e.g. app.abc123.css) // enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction()) .enableVersioning(Encore.isProduction())
// configure Babel .configureBabel((config) => {
// .configureBabel((config) => { config.plugins.push('@babel/plugin-proposal-class-properties');
// config.plugins.push('@babel/a-babel-plugin'); })
// })
// enables and configure @babel/preset-env polyfills // enables @babel/preset-env polyfills
.configureBabelPresetEnv((config) => { .configureBabelPresetEnv((config) => {
config.useBuiltIns = 'usage'; config.useBuiltIns = 'usage';
config.corejs = '3.23'; config.corejs = 3;
}) })
// enables Sass/SCSS support // enables Sass/SCSS support

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save