-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Store user_webdavauth users in DB + code cleanup #12799
Conversation
I forgot this app already. ;-) |
@DeepDiver1975 Our CI is running amok again :-( |
if(substr($returnCode, 0, 1) === '2') { | ||
if(!$this->userExists($uid)) { | ||
$query = $this->db->prepareQuery('INSERT INTO `'.$this->tableName.'` (`uid`) VALUES (?)'); | ||
$query->bindValue(1, $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.
@MorrisJobke @DeepDiver1975 I wanted to mock bindValue
also in the tests. But somehow it never worked. Any idea? - I just noticed that it is not really within the defined class and is just annotated:
core/lib/private/db/statementwrapper.php
Lines 9 to 17 in 8fd90e0
/** | |
* small wrapper around \Doctrine\DBAL\Driver\Statement to make it behave, more like an MDB2 Statement | |
* | |
* @method boolean bindValue(mixed $param, mixed $value, integer $type = null); | |
* @method string errorCode(); | |
* @method array errorInfo(); | |
* @method integer rowCount(); | |
* @method array fetchAll(integer $fetchMode = null); | |
*/ |
Any idea?
@blizzz I guess this makes |
@LukasReschke did not test, but code-wise you fixed the issue. A potential thing: in checkPassword(), if webdav does not care about case sensitivity, $uid could have different cases, resulting in different users. If this is the case, consider lowercasing it. Also, since webdav users can show up out of nothing, the returned $uid in checkPassword could collide with an existing user. It's like creating a user without name checks. I.e. it could be crafted to get access to the data of a local or other user. In LDAP, I check available names before returning a new username. |
True. Needs investigation.
I guess you do that by querying the usermanager before and asking if the user exists? |
You know my methods, Watson. |
@blizzz THX for the heads-up. Incorporated your comments. |
(failing test is unrelated) |
Well - in the past months almost any user backend we implemented in some point in time introduced it's own table to store the users. We might want to think about some consolidation ..... |
*/ | ||
public function getHome($uid) { | ||
if ($this->userExists($uid)) { | ||
return $this->config->getSystemValue('datadirectory', $this->serverRoot . '/data') . '/' . $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.
wouldn't it make more sense to have an api to get the data dir instead of implementing this logic in several places? THX
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.
Agreed
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.
just return false or don't implement it – getHome() is only to override ownCloud default.
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.
@MorrisJobke as blizzz explained - no need to implement this function - just kill it.
serverroot should no longer be required as well - THX
The problem I see there is that we will loose a lot of flexibility with that approach. User backends might allow different login names (for example the LDAP app does this) and also might require the need to store additional information about the backend. (for example the remote server if we're going to support such scenarios in the future) I'm not quite sure how we can tackle this with a single table. |
@LukasReschke rebase needed |
7fc1b66
to
50deaab
Compare
</field> | ||
|
||
<index> | ||
<name>webdav_uid</name> |
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.
We require PKs on all tables - please add
<primary>true</primary>
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
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.
Reminder to myself: Learn more about that mysterious database.xml - THX! ;-)
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
???
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 thought I added a commit to this branch o.O
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.
Database noob here: Isn't the unique
one line below exactly the same? 🙈
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.
Unique != primary ;)
50deaab
to
b5c62d7
Compare
I rebase, fixed the merge conflict and added the primary key. But I'm not able to fix the other stuff. @LukasReschke Can you have a look at this? |
I also dropped the method |
I think it's better to keep this for 8.1 now. |
a3408f6
to
d25340c
Compare
Rebased. Ready to review. |
* @return \OCP\IDateTimeZone | ||
* Get the timezone of the current user, based on his session information and config data | ||
* | ||
* @return \DateTimeZone |
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.
the server is meant to return ocp interfaces
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.
🙈
d25340c
to
7723c53
Compare
This commit introduces the storing of user_webdavauth users in the database which is a pre-requisite of #12620. Furthermore, I refactored the code and removed deprecated code, as a little gimmick I added unit tests for the backend. Conflicts: lib/private/server.php Conflicts: apps/user_webdavauth/appinfo/app.php apps/user_webdavauth/user_webdavauth.php
7723c53
to
d4fc829
Compare
Rebased as well. |
Refer to this link for build results (access rights to CI server needed): |
The inspection completed: 51 new issues, 32 updated code elements |
Hello. I think this is the same for all external authentication methods (apart from LDAP, which can map LDAP groups to OC groups, I guess) |
@DeepDiver1975 @LukasReschke Still something for 8.1? |
Refer to this link for build results (access rights to CI server needed): |
@LukasReschke You said, that you want to have a look at this :) |
@LukasReschke 9.0 ???? |
Replaced by #19229 then I guess. |
yep |
This commit introduces the storing of user_webdavauth users in the database which is a pre-requisite of #12620.
Furthermore, I refactored the code and removed deprecated code, as a little gimmick I added unit tests for the backend. - Especially considering that some people are using this as reference implementation for an authentication backend I consider it important that this backend follows best-practises. (still not perfect - but way better)
@MorrisJobke Please review.
@karlitschek Thought you might like that since you created that app. Care to review as well? - Don't worry, most of the change are unit tests :-)