github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/egress/redact.go (about) 1 package egress 2 3 import ( 4 "github.com/livekit/protocol/livekit" 5 "github.com/livekit/protocol/utils" 6 ) 7 8 func RedactUpload(req UploadRequest) { 9 if s3 := req.GetS3(); s3 != nil { 10 s3.AccessKey = utils.Redact(s3.AccessKey, "{access_key}") 11 s3.Secret = utils.Redact(s3.Secret, "{secret}") 12 return 13 } 14 15 if gcp := req.GetGcp(); gcp != nil { 16 gcp.Credentials = utils.Redact(gcp.Credentials, "{credentials}") 17 return 18 } 19 20 if azure := req.GetAzure(); azure != nil { 21 azure.AccountName = utils.Redact(azure.AccountName, "{account_name}") 22 azure.AccountKey = utils.Redact(azure.AccountKey, "{account_key}") 23 return 24 } 25 26 if aliOSS := req.GetAliOSS(); aliOSS != nil { 27 aliOSS.AccessKey = utils.Redact(aliOSS.AccessKey, "{access_key}") 28 aliOSS.Secret = utils.Redact(aliOSS.Secret, "{secret}") 29 return 30 } 31 } 32 33 func RedactAutoEncodedOutput(out AutoEncodedOutput) { 34 if files := out.GetFileOutputs(); len(files) == 1 { 35 RedactUpload(files[0]) 36 } 37 if segments := out.GetSegmentOutputs(); len(segments) == 1 { 38 RedactUpload(segments[0]) 39 } 40 } 41 42 func RedactEncodedOutputs(out EncodedOutput) { 43 RedactAutoEncodedOutput(out) 44 45 if streams := out.GetStreamOutputs(); len(streams) == 1 { 46 RedactStreamKeys(streams[0]) 47 } 48 if images := out.GetImageOutputs(); len(images) == 1 { 49 RedactUpload(images[0]) 50 } 51 52 if o, ok := out.(EncodedOutputDeprecated); ok { 53 if file := o.GetFile(); file != nil { 54 RedactUpload(file) 55 } else if stream := o.GetStream(); stream != nil { 56 RedactStreamKeys(stream) 57 } else if segment := o.GetSegments(); segment != nil { 58 RedactUpload(segment) 59 } 60 } 61 } 62 63 func RedactDirectOutputs(out DirectOutput) { 64 if f := out.GetFile(); f != nil { 65 RedactUpload(f) 66 } 67 } 68 69 func RedactStreamKeys(stream *livekit.StreamOutput) { 70 for i, url := range stream.Urls { 71 if redacted, ok := utils.RedactStreamKey(url); ok { 72 stream.Urls[i] = redacted 73 } 74 } 75 }