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

Initial rewrite for changes in the Bootstrapping module #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Firesphere
Copy link
Collaborator

This is awaiting the merge on the bootstrap module

  • Removed separate handler and form requirements
  • Implement the interfaces
  • Switch to use Spomky-labs OTPHP module
  • Simplified TOTPProvider
  • Added analysis YML's

Copy link
Collaborator

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

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

Hey @Firesphere, I have no experience with these modules at all yet, but I've had a quick skim over the changes and have left a few minor comments here and there. Nice work!

- "**.php"
exclude_paths:
- docs/*
- tests/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't use codeclimate as a part of our regular CI toolchain at the moment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair enough, it's just a copy-paste from other modules. I don't mind removing it

src/Authenticators/TOTPAuthenticator.php Show resolved Hide resolved
return TOTPLoginHandler::create($link, $this);
$algorithm = self::config()->get('algorithm');

return in_array(strtolower($algorithm), ['sha1', 'sha256', 'sha512'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could make this either a config array OR a class constant (if we don't want it to be configurable)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd go with constants, but I think it came from a change @elliot-sawyer made somewhere else


return in_array(strtolower($algorithm), ['sha1', 'sha256', 'sha512'])
? $algorithm
: 'sha1';
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you did go with the above, then this could also be a constant e.g. self::ALGORITHM_DEFAULT

}

/**
* @param $data
* @param HTTPRequest $request
* @param $token
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor point: missing the type

/**
* @param BootstrapMFALoginHandler $controller
* @param string $name
* @return TOTPForm|BootstrapMFALoginForm
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could possibly benefit from being a bit tighter. I see two possibilities:

  • TOTPForm is changed to extend BootstrapMFALoginForm
  • We use LoginForm as the return hint instead

src/Extensions/MemberExtension.php Show resolved Hide resolved
src/Extensions/MemberExtension.php Show resolved Hide resolved
$fields->push(PasswordField::create('token', _t(self::class . '.TOTPCODE', 'TOTP Code')));
$fields = FieldList::create([
PasswordField::create('token', _t(self::class . '.TOTPCODE', 'TOTP Code')),
HiddenField::create('AuthenticationMethod', $this->authenticator_class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI I've made a PR to add a getAuthenticatorClass() method to use here instead of accessing this property directly: silverstripe/silverstripe-framework#8571

Won't be useful until this module requires 4.4 or newer though

src/Providers/TOTPProvider.php Show resolved Hide resolved
Copy link
Collaborator

@NightJar NightJar left a comment

Choose a reason for hiding this comment

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

Looks good, all things are only minor from what we can see (@NightJar @ScopeyNZ pair peer review)
Seems like a first step as it is, as the BootstrapMFA is changing it's API to be more flexible.

At some point we will need to stop and take stock of both modules (and other MFA Authenticators) together, so we are happy for this to be merged now, and have follow-ups later.

All open unresolved comments should be converted to issues first before merging, except this one, which should just be done now: https://github.com/elliot-sawyer/totp-authenticator/pull/18/files?utf8=%E2%9C%93&diff=split#r230733713

{
return TOTPLoginHandler::create($link, $this);
$algorithm = self::config()->get('algorithm');
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be static::config() to allow for late static binding & the ability for subclasses to have their own specific config.

@robbieaverill
Copy link
Collaborator

There's also a few merge conflicts that need to be resolved

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

Successfully merging this pull request may close these issues.

3 participants