Skip to content

Event for failed login attempts - #19845

Merged
rullzer merged 1 commit into
masterfrom
enh/events/loginFailedEvent
Mar 31, 2020
Merged

Event for failed login attempts#19845
rullzer merged 1 commit into
masterfrom
enh/events/loginFailedEvent

Conversation

@rullzer

Copy link
Copy Markdown
Member

First start of a failed login event.
So we can act on it in other parts.

@rullzerrullzer added this to the Nextcloud 19 milestone Mar 7, 2020

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

New class needs @since annotations, but the rest seems fine :)

@blizzzblizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

terms are being mixed up here :(

Please use

  • loginName, when it is about the value that is entered as name in the login form
  • userId, or short uid, when the value exactly and without doubt matches the user id of the user
  • username, rather don't

@rullzer
rullzerforce-pushed the enh/events/loginFailedEvent branch from 5d00e5d to 5135888CompareMarch 30, 2020 14:30
@rullzer

Copy link
Copy Markdown
MemberAuthor

/compile amend /

@rullzer
rullzer requested a review from blizzzMarch 30, 2020 14:34
'preLoginNameUsedAsUserName',
['uid' => &$uid]
);
$this->dispatcher->dispatchTyped(new LoginFailedEvent($uid));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

possible doing a userExists checks against the uid, and only emitting it against existing users? of course it could be done by the consumer, too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's to good to be clear in what is actually passed in the arguments, to avoid surprises.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Problem is that this still doesn't give the right UID in all cases. Normal backend is case insensitive etc.

I mean in the password policy app we could always do a 'userExist' check.

@blizzzblizzzMar 30, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should give the correct uid when the user exists, and leave it unchanged otherwise. But let me double check.

There might be a use case if you try to make fail2ban thing on NC level, when you don't care about an existing user behind a login name (just, it's on the wrong level, you have fail2ban already). But then, we should leave the preLoginNameUsedAsUserName to the consumer, too, as it is not necessary for this hypothetic use case.

So I'd say, when we start with preLoginNameUsedAsUserName, let's do the full thing and only emit when an existing user account is behind that, instead of a half hearted approach.

Update: committed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Normal backend is case insensitive etc.

It returns the uid in the correct from

Comment threadlib/private/User/Session.php Outdated
'preLoginNameUsedAsUserName',
['uid' => &$uid]
);
$this->dispatcher->dispatchTyped(new LoginFailedEvent($user));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see above

@npmbuildbot-nextcloud
npmbuildbot-nextcloudBotforce-pushed the enh/events/loginFailedEvent branch from 5135888 to 826e243CompareMarch 30, 2020 14:39

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

Comment threadlib/private/Authentication/Login/LoggedInCheckCommand.php Outdated
@ChristophWurst

Copy link
Copy Markdown
Member

Bildschirmfoto von 2020-03-31 09-08-22

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@rullzer
rullzerforce-pushed the enh/events/loginFailedEvent branch from 9906270 to 84f3d2dCompareMarch 31, 2020 19:41
@rullzerrullzer changed the title [POC] Event for failed login attemptsEvent for failed login attemptsMar 31, 2020
@rullzer
rullzer merged commit b39fb55 into masterMar 31, 2020
@rullzer
rullzer deleted the enh/events/loginFailedEvent branch March 31, 2020 20:17
ChristophWurst added a commit to nextcloud/documentation that referenced this pull request Apr 10, 2020
ChristophWurst added a commit to nextcloud/documentation that referenced this pull request Apr 10, 2020
Ref #1951
Ref nextcloud/server#19845
Ref nextcloud/server#19075
Ref nextcloud/server#14722
Ref nextcloud/server#19321
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developingWork in progressenhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@rullzer@ChristophWurst@blizzz