mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: audit login (#5925)
* added migration for api key resource * sort of working * auditing login * passing the correct user id * added and fixed tests * gen documentation * formatting and lint * lint * audit Github oauth and write tests * audit oauth and write tests * added defer fn for login error auditing * fixed test * feat: audit logout (#5998) * Update coderd/userauth.go Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com> * fix test * bypassing diff generation if login/logout * lint --------- Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
This commit is contained in:
@ -264,6 +264,12 @@ func auditLogDescription(alog database.GetAuditLogsOffsetRow, additionalFields a
|
||||
codersdk.AuditAction(alog.Action).Friendly(),
|
||||
)
|
||||
|
||||
// API Key resources do not have targets and follow the below format:
|
||||
// "User {logged in | logged out}"
|
||||
if alog.ResourceType == database.ResourceTypeApiKey {
|
||||
return str
|
||||
}
|
||||
|
||||
// Strings for starting/stopping workspace builds follow the below format:
|
||||
// "{user | 'Coder automatically'} started build #{build_number} for workspace {target}"
|
||||
// where target is a workspace (name) instead of a workspace build
|
||||
@ -488,6 +494,10 @@ func actionFromString(actionString string) string {
|
||||
return actionString
|
||||
case codersdk.AuditActionStop:
|
||||
return actionString
|
||||
case codersdk.AuditActionLogin:
|
||||
return actionString
|
||||
case codersdk.AuditActionLogout:
|
||||
return actionString
|
||||
default:
|
||||
}
|
||||
return ""
|
||||
|
Reference in New Issue
Block a user