@@ -151,9 +151,10 @@ func SignKey(caKeyLocation, keyID, principals, expiration, publicKey string) (si
151151 return string (signatureBytes ), nil
152152}
153153
154- // Get the principals that should be placed in the signed certificate.
155- // Note that this function is a security boundary since if it was bypassed an
156- // attacker would be able to provision SSH keys for environments that they should not have access to.
154+ // Get the principals that should be placed in the signed certificate. Note
155+ // that this function is a security boundary since if it was bypassed an
156+ // attacker would be able to provision SSH keys for environments that they
157+ // should not have access to.
157158func getPrincipals (conf config.Config , sr shared.SignatureRequest ) (string , error ) {
158159 // Start by getting the list of teams the user is in
159160 api , err := botwrapper .GetKBChat (conf .GetKeybaseHomeDir (), conf .GetKeybasePaperKey (), conf .GetKeybaseUsername (), conf .GetKeybaseTimeout ())
@@ -165,11 +166,13 @@ func getPrincipals(conf config.Config, sr shared.SignatureRequest) (string, erro
165166 return "" , fmt .Errorf ("failed to retrieve the list of teams the user is in: %v" , err )
166167 }
167168
168- // Maps from a team to whether or not the user is in the current team (with writer, admin, or owner permissions)
169+ // Maps from a team to whether or not the user is in the current team (with
170+ // writer, admin, or owner permissions)
169171 teamToMembership := make (map [string ]bool )
170172 for _ , result := range results {
171- if result .Role != 0 {
172- // result.Role == 0 means they are an impicit admin in the team and are not actually a member
173+ // Check if the user is actually in the team, and not a restricted bot
174+ // or implicit admin.
175+ if shared .CanRoleReadTeam (result .Role ) {
173176 teamToMembership [result .FqName ] = true
174177 }
175178 }
0 commit comments