-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Backend interfaces #8935
Backend interfaces #8935
Conversation
I like this approach. It's much cleaner than my suggestion from PR #8896 and user backend developers now have a clear starting point (which is Of course this also closes #8895. |
aec2e31
to
37ac8f5
Compare
Codecov Report
@@ Coverage Diff @@
## master #8935 +/- ##
=========================================
Coverage ? 51.97%
Complexity ? 25278
=========================================
Files ? 1604
Lines ? 94896
Branches ? 1388
=========================================
Hits ? 49321
Misses ? 45575
Partials ? 0
|
Yes that is fine. As long as you only use the OCP namespace it is all good. |
This is so much cleaner 👍 Nice 😄 |
@MorrisJobke I'll see if I can convert our db backend into this. And if all test still pass then I'd vote to get it in and move all other backens over slowly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YESS! Way to go! 🙌
Just a tiny note: since we're using the I
prefix for interfaces (I assume someone with a C# or similar background started this), I wonder if we should use A
for abstract classes, like ABackend
. I'm fine with either.
Fine with me. @nickvergessen @blizzz @schiessle Opinions? |
*/ | ||
interface ICheckPasswordBackend { | ||
/** | ||
* @since 14.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document the return values and usage for all those methods as well? (just take the ones from the DatabaseBackend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -302,6 +302,15 @@ | |||
'OCP\\Template' => $baseDir . '/lib/public/Template.php', | |||
'OCP\\User' => $baseDir . '/lib/public/User.php', | |||
'OCP\\UserInterface' => $baseDir . '/lib/public/UserInterface.php', | |||
'OCP\\User\\Backend\\AbstractBackend' => $baseDir . '/lib/public/User/Backend/AbstractBackend.php', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no up to date with latest changes
@@ -332,6 +332,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c | |||
'OCP\\Template' => __DIR__ . '/../../..' . '/lib/public/Template.php', | |||
'OCP\\User' => __DIR__ . '/../../..' . '/lib/public/User.php', | |||
'OCP\\UserInterface' => __DIR__ . '/../../..' . '/lib/public/UserInterface.php', | |||
'OCP\\User\\Backend\\AbstractBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/AbstractBackend.php', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no up to date with latest changes
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Because we don't return consistent things yet :( Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
385374d
to
f5ce253
Compare
* @param int $actions The action to check for | ||
* @return bool | ||
*/ | ||
public function implementsActions($actions): bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason there is no int
type hinted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because this inherits from the old interfaces. And there is no typehint there.
Adding the typehint will make any userbackend do 💥 (including LDAP).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
* @param string $password The password | ||
* @return string|bool The uid on success false on failure | ||
*/ | ||
public function checkPassword(string $loginName, string $password); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to type hint the success case and expect an exception on failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would. But lets do baby steps. First get this in and then have an issue/PR to discuss further steps and improvements. Because if we change all that we also have to change all the logic that is calling this etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay 👍
* | ||
* @return int|bool The number of users on success false on failure | ||
*/ | ||
public function countUsers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same exception handling here.
* @param string $uid the username | ||
* @return string|bool Datadir on success false on failure | ||
*/ | ||
public function getHome(string $uid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same exception handling here.
* @param string $password The password of the new user | ||
* @return bool | ||
*/ | ||
public function createUser(string $uid, string $password): bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect it to succeed or to throw an exception. So there should not be any return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't change that without chaning the whole backend logic as well. It will happen but baby steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
* @param string $displayName The new display name | ||
* @return bool | ||
*/ | ||
public function setDisplayName(string $uid, string $displayName): bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect it to succeed or to throw an exception. So there should not be any return value.
* @param string $password The new password | ||
* @return bool | ||
*/ | ||
public function setPassword(string $uid, string $password): bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect it to succeed or to throw an exception. So there should not be any return value.
Could have also started to use full words (Interface and Abstract) instead of introducing A now ;) |
This PR introduces interfaces to get rid of implementsActions of the user backends. Using interfaces here is much cleaner and actually what they were designed for.
I also created an abstractbackend that makes sure that backends using this new interface will continue to work as we slowly move over all the backends.
@klada @MorrisJobke how does this look?