Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an ALTCHA form field to the form generator #7054

Open
wants to merge 8 commits into
base: 5.x
Choose a base branch
from

Conversation

markocupic
Copy link
Contributor

As agreed with @Toflar on Slack, this PR delivers the integration of Altcha https://altcha.org/ for Contao 5.x

What are the thinks still needs to be done?

  • One point that is still open is the lack of unit tests, because I have too little experience in writing unit tests.

  • The translations are also missing.

  • The Altcha script is currently in the public directory and probably needs to be moved.

  • Please also take a close look at the widget class \Contao\AltchaForm. I am not sure if everything is 100% correct.

@ContaoCoreTeam Have a look at it and I look forward to constructive feedback 🌞

@leofeyer leofeyer added this to the 5.4 milestone Mar 24, 2024
@leofeyer leofeyer changed the title This commit adds an Altcha antispam form field to the Contao form man… Add an ALTCHA antispam widget to the form generator Mar 25, 2024
@leofeyer leofeyer changed the title Add an ALTCHA antispam widget to the form generator Add an ALTCHA anti-spam widget to the form generator Mar 25, 2024
@leofeyer leofeyer changed the title Add an ALTCHA anti-spam widget to the form generator Add an ALTCHA widget to the form generator Mar 25, 2024
@leofeyer leofeyer changed the title Add an ALTCHA widget to the form generator Add an ALTCHA form field to the form generator Mar 25, 2024
@Toflar Toflar added the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Mar 25, 2024
@leofeyer leofeyer removed the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Apr 4, 2024
Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Marko, first of all, thank you so much for taking the time to work on this ❤️ We have discussed this in today's call and here is a first feedback.
Also some general info:

  • @leofeyer will prepare a component for your altcha.js
  • We don't need the Pow prefix/namespace you have added everywhere, you can just omit that :)
  • Translations: You don't have to worry about them, we only manage the English translations and then synchronize translations using transifex. So the current state of the PR is perfect 👍
  • Regarding the unit tests: Do you want to give it a try and learn something new? For the AltchaController and the PurgeExpiredAltchaChallengesCron things should be fairly straightforwad because we already have other controllers and cronjobs where you could check how the unit tests are written. This would probably be a good start? For the Altcha service itself, we can also help 😊 (we can also for the rest, just wanted to check if you want to learn something new first 😎 )

core-bundle/src/Controller/PowAltchaController.php Outdated Show resolved Hide resolved
core-bundle/src/DependencyInjection/Configuration.php Outdated Show resolved Hide resolved
core-bundle/src/DependencyInjection/Configuration.php Outdated Show resolved Hide resolved
core-bundle/src/Entity/PowAltcha.php Outdated Show resolved Hide resolved
core-bundle/src/Entity/PowAltcha.php Outdated Show resolved Hide resolved
core-bundle/src/Pow/Altcha/Config/AlgorithmConfig.php Outdated Show resolved Hide resolved
core-bundle/src/Pow/Altcha/Altcha.php Outdated Show resolved Hide resolved
core-bundle/src/Pow/Altcha/Validator/AltchaValidator.php Outdated Show resolved Hide resolved
core-bundle/src/Cron/PurgeExpiredAltchaChallengesCron.php Outdated Show resolved Hide resolved
core-bundle/src/Pow/Altcha/Altcha.php Outdated Show resolved Hide resolved
core-bundle/src/Pow/Altcha/Altcha.php Outdated Show resolved Hide resolved
Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks already very good now! I have reviewed some more - after that, on to the tests I guess ;)

core-bundle/src/Controller/AltchaController.php Outdated Show resolved Hide resolved
core-bundle/contao/languages/en/default.xlf Outdated Show resolved Hide resolved
core-bundle/src/Altcha/Config/AlgorithmConfig.php Outdated Show resolved Hide resolved
core-bundle/src/DependencyInjection/Configuration.php Outdated Show resolved Hide resolved
// The challenge expires in 1 hour (default) and it must be saved in the database
// to prevent replay attacks.
$expiryDate = date('Y-m-d\\TH:i:sP', time() + $this->altchaChallengeExpiry);
$objAltcha = new AltchaEntity($challenge, new \DateTimeImmutable($expiryDate));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this cannot work because that class does not exist (that's why we need tests ;)).

@leofeyer
Copy link
Member

The script is now available as Contao component: https://packagist.org/packages/contao-components/altcha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants