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

API Moving verification logic to a trait for easier re-usability #102

Conversation

ScopeyNZ
Copy link
Contributor

  • Moves configuration for the required number of verified methods to the EnforcementManager
  • StoreInterface now requires a member. A store cannot be created without one
  • Parts of the code have been updated to handle the new ?StoreInterface return type of getStore
  • Updated API responses to return 403 instead of redirects when session timeouts occur
  • Added a LoginHandler trait that provides methods for handling requests and responses to and from the MFA React app
  • SessionStore implements Serializable so it can be added to the session directly
  • Moved tracking of completed "verified methods" to StoreInterface.
  • Moved loading of existing StoreInterfaces to the interface

- Moves configuration for the required number of verified methods to the EnforcementManager
- `StoreInterface` now requires a member. A store cannot be created without one
- Parts of the code have been updated to handle the new `?StoreInterface` return type of `getStore`
- Updated API responses to return `403` instead of redirects when session timeouts occur
- Added a `LoginHandler` trait that provides methods for handling requests and responses to and from the MFA React app
- `SessionStore` implements `Serializable` so it can be added to the session directly
- Moved tracking of completed "verified methods" to `StoreInterface`.
- Moved loading of existing `StoreInterface`s to the interface
@ScopeyNZ ScopeyNZ force-pushed the pulls/4/extract-login-logic branch from beb2451 to 0b2a6c0 Compare April 23, 2019 21:18
Copy link
Contributor

@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.

Seems great :)

@@ -666,7 +570,7 @@ protected function doPerformLogin(HTTPRequest $request, Member $member)
// These next two lines are pulled from "parent::doLogin()"
$this->performLogin($member, $data, $request);
// Allow operations on the member after successful login
$this->extend('onLoginSuccess', $member);
parent::extend('afterLogin', $member);
Copy link
Contributor

Choose a reason for hiding this comment

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

For public visibility, here's a summary of what we discussed internally with this change:

  • We can't delegate to the parent method on success, because the member data is gone at this point. We overload it instead.
  • The afterLogin hook comes from the parent class, and I removed it thinking we didn't need it in NEW Add extension points for audit logging in method registration, login and skip points #103.
  • The onLoginSuccess hook is something we added and don't actually need.
  • We're asking the parent to express the extension hook, because people may have listeners attached to the parent class rather than this child.

Copy link
Contributor

@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.

Love it, some minor suggestions

src/RequestHandler/LoginHandlerTrait.php Outdated Show resolved Hide resolved
src/RequestHandler/LoginHandlerTrait.php Outdated Show resolved Hide resolved
src/Service/MethodRegistry.php Outdated Show resolved Hide resolved
src/Store/SessionStore.php Show resolved Hide resolved
src/Store/SessionStore.php Outdated Show resolved Hide resolved
@robbieaverill robbieaverill merged commit d5aa5ca into silverstripe:master Apr 23, 2019
@robbieaverill robbieaverill deleted the pulls/4/extract-login-logic branch April 23, 2019 22:21
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.

None yet

3 participants