Skip to content

Commit

Permalink
chore: remove governance related code
Browse files Browse the repository at this point in the history
Governance feature is not being used in any of the flows.

Signed-off-by: Rolson Quadras <[email protected]>
  • Loading branch information
rolsonquadras committed Jan 26, 2022
1 parent fe16daf commit 15c24bd
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 1,210 deletions.
54 changes: 1 addition & 53 deletions cmd/adapter-rest/startcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import (
tlsutils "github.com/trustbloc/edge-core/pkg/utils/tls"

"github.com/trustbloc/edge-adapter/pkg/did"
"github.com/trustbloc/edge-adapter/pkg/governance"
"github.com/trustbloc/edge-adapter/pkg/hydra"
"github.com/trustbloc/edge-adapter/pkg/ld"
"github.com/trustbloc/edge-adapter/pkg/presentationex"
Expand Down Expand Up @@ -180,10 +179,6 @@ const (
" Alternatively, this can be set with the following environment variable: " + logLevelEnvKey
logLevelEnvKey = "ADAPTER_REST_LOGLEVEL"

governanceVCSURLFlagName = "governance-vcs-url"
governanceVCSURLFlagUsage = "Governance VCS instance is running on. Format: HostName:Port."
governanceVCSURLEnvKey = "ADAPTER_REST_GOVERNANCE_VCS_URL"

requestTokensFlagName = "request-tokens"
requestTokensEnvKey = "ADAPTER_REST_REQUEST_TOKENS" // nolint: gosec
requestTokensFlagUsage = "Tokens used for http request " +
Expand Down Expand Up @@ -306,7 +301,6 @@ type adapterRestParameters struct {
didCommParameters *didCommParameters // didcomm
trustblocDomain string
universalResolverURL string
governanceVCSURL string
requestTokens map[string]string
walletAppURL string
oidcClientDBKeyPath string
Expand All @@ -316,12 +310,6 @@ type adapterRestParameters struct {
cmOutputDescriptorsFilePath string
}

// governanceProvider governance provider.
type governanceProvider interface {
IssueCredential(didID, profileID string) ([]byte, error)
GetCredential(profileID string) ([]byte, error)
}

type server interface {
ListenAndServe(host, certFile, keyFile string, router http.Handler) error
}
Expand Down Expand Up @@ -442,12 +430,6 @@ func getAdapterRestParameters(cmd *cobra.Command) (*adapterRestParameters, error
return nil, fmt.Errorf(confErrMsg, err)
}

governanceVCSURL, err := cmdutils.GetUserSetVarFromString(cmd, governanceVCSURLFlagName,
governanceVCSURLEnvKey, true)
if err != nil {
return nil, fmt.Errorf(confErrMsg, err)
}

requestTokens, err := getRequestTokens(cmd)
if err != nil {
return nil, fmt.Errorf(confErrMsg, err)
Expand Down Expand Up @@ -485,7 +467,6 @@ func getAdapterRestParameters(cmd *cobra.Command) (*adapterRestParameters, error
didCommParameters: didCommParameters,
trustblocDomain: trustblocDomain,
universalResolverURL: universalResolverURL,
governanceVCSURL: governanceVCSURL,
requestTokens: requestTokens,
walletAppURL: walletAppURL,
oidcClientDBKeyPath: issuerOIDCKeyPath,
Expand Down Expand Up @@ -650,7 +631,6 @@ func createFlags(startCmd *cobra.Command) {
startCmd.Flags().StringP(presentationDefinitionsFlagName, "", "", presentationDefinitionsFlagUsage)
startCmd.Flags().StringP(hydraURLFlagName, "", "", hydraURLFlagUsage)
startCmd.Flags().StringP(modeFlagName, "", "", modeFlagUsage)
startCmd.Flags().StringP(governanceVCSURLFlagName, "", "", governanceVCSURLFlagUsage)
startCmd.Flags().StringArrayP(requestTokensFlagName, "", []string{}, requestTokensFlagUsage)

// didcomm
Expand Down Expand Up @@ -773,18 +753,6 @@ func addRPHandlers(parameters *adapterRestParameters, framework *aries.Aries, ro
return fmt.Errorf("failed to init edge storage: %w", err)
}

var governanceProv governanceProvider

if parameters.governanceVCSURL != "" {
var errNew error

governanceProv, errNew = newGovernanceProvider(parameters.governanceVCSURL, rootCAs, store,
parameters.requestTokens, parameters.trustblocDomain)
if errNew != nil {
return fmt.Errorf("failed to create governance provider: %w", errNew)
}
}

// TODO init OIDC stuff in iteration 2 - https://github.com/trustbloc/edge-adapter/issues/24

didCreator, err := did.NewTrustblocDIDCreator(
Expand Down Expand Up @@ -814,7 +782,6 @@ func addRPHandlers(parameters *adapterRestParameters, framework *aries.Aries, ro
AriesContextProvider: ctx,
AriesMessenger: framework.Messenger(),
MsgRegistrar: msgRegistrar,
GovernanceProvider: governanceProv,
PresentProofClient: presentProofClient,
WalletBridgeAppURL: parameters.walletAppURL,
JSONLDDocumentLoader: ctx.JSONLDDocumentLoader(),
Expand Down Expand Up @@ -844,26 +811,14 @@ func addRPHandlers(parameters *adapterRestParameters, framework *aries.Aries, ro
return nil
}

// nolint:funlen,gocyclo,cyclop
// nolint:funlen
func addIssuerHandlers(parameters *adapterRestParameters, framework *aries.Aries, router *mux.Router,
rootCAs *x509.CertPool, msgRegistrar *msghandler.Registrar) error {
store, err := initStore(parameters.dsnParams.dsn, parameters.dsnParams.timeout, issuerAdapterStorePrefix)
if err != nil {
return fmt.Errorf("failed to init storage provider : %w", err)
}

var governanceProv governanceProvider

if parameters.governanceVCSURL != "" {
var errNew error

governanceProv, errNew = newGovernanceProvider(parameters.governanceVCSURL, rootCAs, store,
parameters.requestTokens, parameters.trustblocDomain)
if errNew != nil {
return fmt.Errorf("failed to init governance provider: %w", errNew)
}
}

ariesCtx, err := framework.Context()
if err != nil {
return fmt.Errorf("aries-framework - failed to get aries context : %w", err)
Expand Down Expand Up @@ -902,7 +857,6 @@ func addIssuerHandlers(parameters *adapterRestParameters, framework *aries.Aries
StoreProvider: store,
PublicDIDCreator: didCreator,
TLSConfig: &tls.Config{RootCAs: rootCAs, MinVersion: tls.VersionTLS12},
GovernanceProvider: governanceProv,
OIDCClientStoreKey: clientStoreKey,
ExternalURL: parameters.externalURL,
DidDomain: parameters.trustblocDomain,
Expand Down Expand Up @@ -941,12 +895,6 @@ func getIssuerOIDCClientStoreKey(keyPath string) ([]byte, error) {
return bytes, nil
}

func newGovernanceProvider(governanceVCSURL string, rootCAs *x509.CertPool,
store storage.Provider, requestTokens map[string]string, domain string) (*governance.Provider, error) {
return governance.New(governanceVCSURL, &tls.Config{RootCAs: rootCAs}, store, // nolint:gosec,wrapcheck
requestTokens, domain)
}

func uiHandler(
basePath string,
fileServer func(http.ResponseWriter, *http.Request, string)) func(http.ResponseWriter, *http.Request) {
Expand Down
4 changes: 0 additions & 4 deletions cmd/adapter-rest/startcmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ func TestAdapterModes(t *testing.T) { // nolint:paralleltest // shared environme
"--" + didCommInboundHostFlagName, randomURL(),
"--" + datasourceNameFlagName, "mem://test",
"--" + datasourceTimeoutFlagName, "30",
"--" + governanceVCSURLFlagName, "http://example.vcs.com",
}
startCmd.SetArgs(args)

Expand Down Expand Up @@ -421,7 +420,6 @@ func TestAdapterModes(t *testing.T) { // nolint:paralleltest // shared environme
"--" + didCommInboundHostFlagName, testInboundHostURL,
"--" + datasourceNameFlagName, "mem://test",
"--" + datasourceTimeoutFlagName, "30",
"--" + governanceVCSURLFlagName, "http://example.vcs.com",
"--" + issuerOIDCClientStoreKeyFlagName, file.Name(),
"--" + cmOutputDescriptorsFilePathFlagName, "./testdata/outputdescriptors.json",
}
Expand Down Expand Up @@ -509,7 +507,6 @@ func TestAdapterModes(t *testing.T) { // nolint:paralleltest // shared environme
"--" + didCommInboundHostFlagName, testInboundHostURL,
"--" + datasourceNameFlagName, "mem://test",
"--" + datasourceTimeoutFlagName, "30",
"--" + governanceVCSURLFlagName, "http://example.vcs.com",
"--" + issuerOIDCClientStoreKeyFlagName, file.Name() + "-nonexistent",
"--" + cmOutputDescriptorsFilePathFlagName, "./testdata/outputdescriptors.json",
}
Expand All @@ -536,7 +533,6 @@ func TestAdapterModes(t *testing.T) { // nolint:paralleltest // shared environme
"--" + didCommInboundHostFlagName, testInboundHostURL,
"--" + datasourceNameFlagName, "mem://test",
"--" + datasourceTimeoutFlagName, "30",
"--" + governanceVCSURLFlagName, "http://example.vcs.com",
"--" + issuerOIDCClientStoreKeyFlagName, file.Name() + "-nonexistent",
"--" + cmOutputDescriptorsFilePathFlagName, file.Name(),
}
Expand Down
153 changes: 0 additions & 153 deletions pkg/governance/provider.go

This file was deleted.

Loading

0 comments on commit 15c24bd

Please sign in to comment.