outpost/ldap: delay user information removal upon closing of connection
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		
							
								
								
									
										32
									
								
								internal/outpost/ldap/close.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								internal/outpost/ldap/close.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| package ldap | ||||
|  | ||||
| import ( | ||||
| 	"net" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| func (ls *LDAPServer) Close(boundDN string, conn net.Conn) error { | ||||
| 	for _, p := range ls.providers { | ||||
| 		p.delayDeleteUserInfo(boundDN) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (pi *ProviderInstance) delayDeleteUserInfo(dn string) { | ||||
| 	ticker := time.NewTicker(30 * time.Second) | ||||
| 	quit := make(chan struct{}) | ||||
| 	go func() { | ||||
| 		for { | ||||
| 			select { | ||||
| 			case <-ticker.C: | ||||
| 				pi.boundUsersMutex.Lock() | ||||
| 				delete(pi.boundUsers, dn) | ||||
| 				pi.boundUsersMutex.Unlock() | ||||
| 				close(quit) | ||||
| 			case <-quit: | ||||
| 				ticker.Stop() | ||||
| 				return | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer