accounts, cmd, internal: disable unlock account on open HTTP (#17037)
* cmd, accounts, internal, node, rpc, signer: insecure unlock protect * all: strict unlock API by rpc * cmd/geth: check before printing warning log * accounts, cmd/geth, internal: tiny polishes
This commit is contained in:
		
				
					committed by
					
						 Péter Szilágyi
						Péter Szilágyi
					
				
			
			
				
	
			
			
			
						parent
						
							9b3601cfce
						
					
				
				
					commit
					d5cae48bae
				
			| @@ -317,7 +317,14 @@ func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (commo | ||||
| // UnlockAccount will unlock the account associated with the given address with | ||||
| // the given password for duration seconds. If duration is nil it will use a | ||||
| // default of 300 seconds. It returns an indication if the account was unlocked. | ||||
| func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *uint64) (bool, error) { | ||||
| func (s *PrivateAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error) { | ||||
| 	// When the API is exposed by external RPC(http, ws etc), unless the user | ||||
| 	// explicitly specifies to allow the insecure account unlocking, otherwise | ||||
| 	// it is disabled. | ||||
| 	if s.b.ExtRPCEnabled() && !s.b.AccountManager().Config().InsecureUnlockAllowed { | ||||
| 		return false, errors.New("account unlock with HTTP access is forbidden") | ||||
| 	} | ||||
|  | ||||
| 	const max = uint64(time.Duration(math.MaxInt64) / time.Second) | ||||
| 	var d time.Duration | ||||
| 	if duration == nil { | ||||
|   | ||||
| @@ -44,6 +44,7 @@ type Backend interface { | ||||
| 	ChainDb() ethdb.Database | ||||
| 	EventMux() *event.TypeMux | ||||
| 	AccountManager() *accounts.Manager | ||||
| 	ExtRPCEnabled() bool | ||||
|  | ||||
| 	// BlockChain API | ||||
| 	SetHead(number uint64) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user