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

Introduce account modules #31547

Merged
merged 1 commit into from Jun 25, 2018
Merged

Introduce account modules #31547

merged 1 commit into from Jun 25, 2018

Conversation

butonic
Copy link
Member

@butonic butonic commented May 28, 2018

This introduces Account Modules using password expiry as an example. Requires owncloud/password_policy#15

@codecov
Copy link

codecov bot commented May 31, 2018

Codecov Report

Merging #31547 into master will increase coverage by <.01%.
The diff coverage is 60.68%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31547      +/-   ##
============================================
+ Coverage      63.4%    63.4%   +<.01%     
- Complexity    18461    18493      +32     
============================================
  Files          1162     1165       +3     
  Lines         69267    69367     +100     
  Branches       1264     1264              
============================================
+ Hits          43920    43984      +64     
- Misses        24978    25014      +36     
  Partials        369      369
Flag Coverage Δ Complexity Δ
#javascript 52.58% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 64.65% <60.68%> (-0.01%) 18493 <28> (+32)
Impacted Files Coverage Δ Complexity Δ
apps/dav/appinfo/v1/carddav.php 0% <0%> (ø) 0 <0> (ø) ⬇️
apps/dav/appinfo/v1/caldav.php 0% <0%> (ø) 0 <0> (ø) ⬇️
lib/private/legacy/util.php 69.91% <0%> (-0.59%) 246 <0> (+1)
apps/dav/appinfo/v1/webdav.php 0% <0%> (ø) 0 <0> (ø) ⬇️
lib/private/legacy/api.php 41.15% <0%> (-1.05%) 85 <0> (+2)
lib/private/legacy/json.php 8.69% <0%> (-0.83%) 29 <1> (+2)
apps/dav/lib/Server.php 51.42% <100%> (+0.34%) 24 <0> (ø) ⬇️
...e/AppFramework/DependencyInjection/DIContainer.php 73.23% <100%> (+0.54%) 81 <0> (ø) ⬇️
core/Middleware/AccountModuleMiddleware.php 100% <100%> (ø) 10 <10> (?)
lib/private/Server.php 85.02% <100%> (+0.12%) 253 <2> (+2) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70fbb2e...c29a99a. Read the comment docs.

@butonic butonic force-pushed the feature/password-expiry branch 7 times, most recently from f4c3b39 to f752182 Compare June 4, 2018 14:16
@butonic
Copy link
Member Author

butonic commented Jun 12, 2018

  • register login hook to check account modules on webdav and ocs login (move code from password policy to core)
    • no, the app providing the account module has to do this itself, because not all account modules may need to check something based on the postLogin event. That is only the case for the force password expiry. An OptInAccountModule eg does not need the password info of the post login event. It is invoked by the AccountModuleMiddleware. Same for a Force2FAAccountModule.
  • add dav plugin reproducing the middleware logic
    • grepped where needsSecondFactor is used ... omg there is not only legacy api.php but also json.php and util.php 😱
    • added account module check there as well 🙄
  • add middleware logic to ocs https://github.com/owncloud/core/blob/master/lib/private/legacy/api.php#L333
  • how do desktop and mobile clients handle forced password reset?
  • should we add a notification that they show the user
    -> password policy, optional, subsequent PR
  • requires configuring forcing token based auth for clients
  • how should clients be affected if an auth module check fails?
    • login should be denied? then all clients will pop up saying login denied.
      • We must show a message what the user should do now.
      • do the clients automatically sync again if login was denied
      • should we return service unavailable to clients?
  • check if we can use a redirect exception instead of IAccountModuleSteps
  • store order in db (appconfig witl json string array), when app is enabled add it to the end ... UI in different PR

@butonic butonic force-pushed the feature/password-expiry branch 9 times, most recently from 62982d0 to 5c0c189 Compare June 14, 2018 13:13
@PVince81
Copy link
Contributor

@SamuAlfageme see questions about clients ^

try {
$this->accountModuleManager->check($user);
} catch (AccountCheckException $ex) {
throw new \Sabre\DAV\Exception\NotAuthenticated($ex->getMessage(), $ex->getCode(), $ex);
Copy link
Member

Choose a reason for hiding this comment

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

this will logout all clients of the user - maybe not what we want - 503 might be a better idea

@@ -236,9 +252,17 @@ private function auth(RequestInterface $request, ResponseInterface $response) {

$data = parent::check($request, $response);
if ($data[0] === true) {
$user = $this->userSession->getUser();
Copy link
Member

Choose a reason for hiding this comment

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

code duplication ...... just saying

Copy link
Member Author

Choose a reason for hiding this comment

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

extracted checkAccountModule($user)

@@ -297,6 +297,7 @@ OC.FileUpload.prototype = {
headers['OC-Total-Length'] = size;

}
headers['OC-LazyOps'] = true;
Copy link
Member

Choose a reason for hiding this comment

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

whot? wrong PR 😬

@@ -381,12 +383,30 @@ public function __construct($appName, $urlParams = []) {
return new TwoFactorMiddleware($twoFactorManager, $userSession, $urlGenerator, $reflector, $request);
});

$this->registerService('AccountModuleManager', function ($c) use ($app) {
Copy link
Member

Choose a reason for hiding this comment

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

should not be necessary - DI magic will create it

);
});

$this->registerService('AccountMiddleware', function (SimpleContainer $c) use ($app) {
Copy link
Member

Choose a reason for hiding this comment

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

same as above - DI magic ..

try {
\OC::$server->getAccountModuleManager()->check($userSession->getUser());
} catch (AccountCheckException $ex) {
// Deny login if any IAuthModule check fails
Copy link
Member

Choose a reason for hiding this comment

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

log?

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -62,24 +63,40 @@ public static function checkAppEnabled($app) {
}
}

/**
* FIXME this needs so much refactoring ...
Copy link
Member

Choose a reason for hiding this comment

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

no fixing - this is legacy - kill it

Copy link
Member Author

Choose a reason for hiding this comment

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

too many references
Too many places where it is still used -> not in this PR. That is why I added a FIXME

Copy link
Member

Choose a reason for hiding this comment

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

I know it's being used - my comment was about the need to kill this all instead of trying to fix this

@@ -0,0 +1,28 @@
<?php

Copy link
Member

Choose a reason for hiding this comment

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

copyright missing

* Interface IAccountModule
*
* @package OCP\Authentication
* @since 10.0.9
Copy link
Member

Choose a reason for hiding this comment

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

10.0.10 - 10.0.9 is out

Copy link
Member Author

Choose a reason for hiding this comment

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

dito

@@ -0,0 +1,21 @@
<?php
/**
* Created by PhpStorm.
Copy link
Member

Choose a reason for hiding this comment

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

copyright

@SamuAlfageme
Copy link

@PVince81 @butonic re. client questions - need some basic instructions for trying this PoC out, I'm not quite familiar with password_policy

@butonic butonic changed the title [PoC] Introduce account modules Introduce account modules Jun 22, 2018
@butonic butonic dismissed DeepDiver1975’s stale review June 22, 2018 13:55

all addressed, please re review

@butonic butonic force-pushed the feature/password-expiry branch 2 times, most recently from 726de89 to 7683e0a Compare June 22, 2018 20:57
* @param $user
* @throws ServiceUnavailable
*/
private function checkAccountModule($user): void {
Copy link
Member

Choose a reason for hiding this comment

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

return type will block backport - we can keep it this way but need to modify this on the backport then

* @param Controller $controller
* @param string $methodName
* @throws AccountCheckException
* @throws \OCP\AppFramework\QueryException
Copy link
Member

Choose a reason for hiding this comment

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

not thrown ?

* @param string $methodName
* @throws AccountCheckException
* @throws \OCP\AppFramework\QueryException
* @throws \OC\NeedsUpdateException
Copy link
Member

Choose a reason for hiding this comment

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

not thrown ?

@@ -281,6 +283,7 @@ public function __construct($appName, $urlParams = []) {
return $this->getServer();
});
$this->registerAlias('OCP\\IServerContainer', 'ServerContainer');
$this->registerAlias(IServiceLoader::class, 'ServerContainer');
Copy link
Member

Choose a reason for hiding this comment

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

I moved this to the core server impl

@@ -62,24 +63,40 @@ public static function checkAppEnabled($app) {
}
}

/**
* FIXME this needs so much refactoring ...
* @param $message
Copy link
Member

Choose a reason for hiding this comment

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

no param

@DeepDiver1975 DeepDiver1975 force-pushed the feature/password-expiry branch 2 times, most recently from fe6962f to 010fb79 Compare June 25, 2018 09:25
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
@DeepDiver1975 DeepDiver1975 merged commit 35eb867 into master Jun 25, 2018
@DeepDiver1975 DeepDiver1975 deleted the feature/password-expiry branch June 25, 2018 12:05
@PVince81 PVince81 added this to the development milestone Jun 25, 2018
@PVince81
Copy link
Contributor

@butonic please backport

@DeepDiver1975
Copy link
Member

@butonic please backport

#31883

@lock
Copy link

lock bot commented Jul 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants