@@ -151,9 +151,10 @@ func SignKey(caKeyLocation, keyID, principals, expiration, publicKey string) (si
151
151
return string (signatureBytes ), nil
152
152
}
153
153
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.
157
158
func getPrincipals (conf config.Config , sr shared.SignatureRequest ) (string , error ) {
158
159
// Start by getting the list of teams the user is in
159
160
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
165
166
return "" , fmt .Errorf ("failed to retrieve the list of teams the user is in: %v" , err )
166
167
}
167
168
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)
169
171
teamToMembership := make (map [string ]bool )
170
172
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 ) {
173
176
teamToMembership [result .FqName ] = true
174
177
}
175
178
}
0 commit comments