Add credential checks

This change adds authentication/credential checks to sensitive API
methods, depending on the access level granted to the authenticated
user. It also adds the logic to save the authenticated user to the audit
log entries.

Note: the protobuf definitions were updated in a backwards-incompatible
way (KillSwitchAuthorizedUser.AccessLevel enum). This can be done since
this product hasn't yet launched.

Fixed: twpowertools:46
Change-Id: I9bf888d6108f463369143610d4bd5b256035b68f
diff --git a/internal/db/kill_switch.go b/internal/db/kill_switch.go
index 8b80286..3c85f2b 100644
--- a/internal/db/kill_switch.go
+++ b/internal/db/kill_switch.go
@@ -91,7 +91,7 @@
 	return killSwitches, nil
 }
 
-func EnableKillSwitch(db *sql.DB, ctx context.Context, k *pb.KillSwitch) error {
+func EnableKillSwitch(db *sql.DB, ctx context.Context, k *pb.KillSwitch, currentUser *pb.KillSwitchAuthorizedUser) error {
 	if k.MinVersion != "" && !isValidSemVersion(k.MinVersion) {
 		return fmt.Errorf("min_version is not a valid semantic version.")
 	}
@@ -148,6 +148,7 @@
 	}
 
 	logEntry := &pb.KillSwitchAuditLogEntry{
+		User: currentUser,
 		Description: &pb.KillSwitchAuditLogEntry_KillSwitchEnabled_{
 			&pb.KillSwitchAuditLogEntry_KillSwitchEnabled{
 				KillSwitch: k,
@@ -162,7 +163,7 @@
 	return tx.Commit()
 }
 
-func DisableKillSwitch(db *sql.DB, ctx context.Context, id int32) error {
+func DisableKillSwitch(db *sql.DB, ctx context.Context, id int32, currentUser *pb.KillSwitchAuthorizedUser) error {
 	oldKillSwitch, err := GetKillSwitchById(db, ctx, id)
 	if err != nil {
 		return err
@@ -188,6 +189,7 @@
 	}
 
 	logEntry := &pb.KillSwitchAuditLogEntry{
+		User: currentUser,
 		Description: &pb.KillSwitchAuditLogEntry_KillSwitchDisabled_{
 			&pb.KillSwitchAuditLogEntry_KillSwitchDisabled{
 				Transformation: &pb.KillSwitchTransformation{