mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	fix an edge case bug that "identity_policies" is nil (#17007)
* check if "identity_policies" is nil to fix cli vault login error * add changelog * skip add identity_policies to resp when there's no identity_policies associated in token's namespace This is an edge case, when an entity has identity_policies associated in other namespaces but no identity_policies in this token's namespace, `identityPolicies[out.NamespaceID]` is nil, client side doesn't handle nil which raises error. * update changelog --------- Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
This commit is contained in:
		| @@ -159,6 +159,10 @@ TOKEN_DONE: | ||||
| 			goto DONE | ||||
| 		} | ||||
|  | ||||
| 		if s.Data["identity_policies"] == nil { | ||||
| 			goto DONE | ||||
| 		} | ||||
|  | ||||
| 		sList, ok := s.Data["identity_policies"].([]string) | ||||
| 		if ok { | ||||
| 			identityPolicies = sList | ||||
|   | ||||
							
								
								
									
										3
									
								
								changelog/17007.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/17007.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| ```release-note:bug | ||||
| auth/token: fixes an edge case bug that "identity_policies" is nil and causes cli vault login error | ||||
| ``` | ||||
| @@ -3435,8 +3435,10 @@ func (ts *TokenStore) handleLookup(ctx context.Context, req *logical.Request, da | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if len(identityPolicies) != 0 { | ||||
| 			resp.Data["identity_policies"] = identityPolicies[out.NamespaceID] | ||||
| 			delete(identityPolicies, out.NamespaceID) | ||||
| 			if _, ok := identityPolicies[out.NamespaceID]; ok { | ||||
| 				resp.Data["identity_policies"] = identityPolicies[out.NamespaceID] | ||||
| 				delete(identityPolicies, out.NamespaceID) | ||||
| 			} | ||||
| 			resp.Data["external_namespace_policies"] = identityPolicies | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tianhao Guo
					Tianhao Guo