-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Propagate accessToken from all HTTP requests to rpc context * Add security module plug-point * Additional test coverage * Enforcement points * Better comments * Allow plugins to be loaded from file * Rename file * HD Wallet support (#45) * Update to geth 1.9.10 and allow hd-u0a1b2c3de-1234 format to from addr on REST * Add plug-point for HDWallet key signing * Extra coverage * Fix gas estimation for HD Wallet signed TX * Ensure addressbook and hdwallet to kafka conf * Rename confusingly named func * Update cmd/plugins.go Co-Authored-By: Vinod Damle <vdamle@users.noreply.github.com> Co-authored-by: Vinod Damle <vdamle@users.noreply.github.com> Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
- Loading branch information
Peter Broadhurst
authored
Jan 31, 2020
1 parent
f1a6095
commit 1c665b7
Showing
55 changed files
with
1,964 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2019 Kaleido | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"plugin" | ||
|
||
"github.com/kaleido-io/ethconnect/internal/kldauth" | ||
"github.com/kaleido-io/ethconnect/pkg/kldplugins" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// PluginConfig is the JSON configuration for loading plugins | ||
type PluginConfig struct { | ||
SecurityModulePlugin string `json:"securityModule"` | ||
} | ||
|
||
func loadPlugins(conf *PluginConfig) error { | ||
if err := loadSecurityModulePlugin(conf); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func loadSecurityModulePlugin(conf *PluginConfig) error { | ||
|
||
modulePath := conf.SecurityModulePlugin | ||
if modulePath == "" { | ||
return nil | ||
} | ||
|
||
log.Debugf("Loading SecurityModule plugin '%s'", modulePath) | ||
smPlugin, err := plugin.Open(modulePath) | ||
if err != nil { | ||
return fmt.Errorf("Failed to load plugin: %s", err) | ||
} | ||
|
||
smSymbol, err := smPlugin.Lookup("SecurityModule") | ||
if err != nil || smSymbol == nil { | ||
return fmt.Errorf("Failed to load 'SecurityModule' symbol from '%s': %s", modulePath, err) | ||
} | ||
|
||
sm, ok := smSymbol.(kldplugins.SecurityModule) | ||
if !ok { | ||
return fmt.Errorf("Failed to cast symbol from '%s' to 'kldplugins.SecurityModule'", modulePath) | ||
} | ||
|
||
kldauth.RegisterSecurityModule(sm) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.