Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: audit login#5925

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Kira-Pilot merged 21 commits intomainfromaudit-login-logout/kira-pilot
Feb 6, 2023
Merged

feat: audit login#5925

Kira-Pilot merged 21 commits intomainfromaudit-login-logout/kira-pilot
Feb 6, 2023

Conversation

Kira-Pilot
Copy link
Member

@Kira-PilotKira-Pilot commentedJan 30, 2023
edited
Loading

Part of#4538
Screen Shot 2023-02-01 at 2 59 13 PM

Logout coming next

kylecarbs reacted with eyes emoji
@Kira-PilotKira-Pilot changed the titlefeat: audit login and logoutfeat: audit loginFeb 1, 2023
var loginWithPassword codersdk.LoginWithPasswordRequest
if !httpapi.Read(ctx, rw, r, &loginWithPassword) {
// We pass a disposable user ID just to force an audit diff
// and generate a log for a failed login
aReq.New = database.APIKey{UserID: uuid.New()}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Down for another approach here. The auditor will skip audit log generation if there's not a valid diff. We don't have a proper UUID onAPIKey and anyways, we bail before we actually create the model. I figured generating a garbage UUID was the fastest path forward but admittedly it's kinda gross.

@@ -995,9 +995,25 @@ func (api *API) organizationByUserAndName(rw http.ResponseWriter, r *http.Reques
// @Success 201 {object} codersdk.LoginWithPasswordResponse
// @Router /users/login [post]
func (api *API) postLogin(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var (
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Does this handler handle all authentication paths? What if a user isn't logging with a password?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a file calleduserauth.go with all of the other ways to login. This endpoint should probably be in there anyways.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Alright, added auditing for OAuth and OIDC. I am not sure how best to smoke-test locally, but I made sure to update all the auth tests.

@Kira-PilotKira-Pilot marked this pull request as ready for reviewFebruary 1, 2023 22:54
return xerrors.Errorf("find linked user: %w", err)
}
user = params.User
link = params.Link
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I thought it was safe to lift finding the user outside of the transaction and into the callers so we can accessUser.ID in those places. If, in the callers, we don't find a user, we bail early, never enteringoauthLogin.

Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

I think we can make things a bit nicer and not repeataReq.New = database.APIKey{} all the time when we return an error. Feels like a bug waiting to happen since we have to always rememeber to put that.

Kira-Pilot reacted with thumbs up emoji
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

Minor nits on comments, LG!

@Kira-PilotKira-Pilot merged commit46fe59f intomainFeb 6, 2023
@Kira-PilotKira-Pilot deleted the audit-login-logout/kira-pilot branchFebruary 6, 2023 20:12
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 6, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk approved these changes

@coadlercoadlerAwaiting requested review from coadler

Assignees

@Kira-PilotKira-Pilot

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Kira-Pilot@Emyrk@coadler

[8]ページ先頭

©2009-2025 Movatter.jp