From 476fbe19b033c0f05d2384fba90771404401efc4 Mon Sep 17 00:00:00 2001 From: Gabe <7622243+decentralgabe@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:41:42 -0700 Subject: [PATCH] uptake latest sdk; add ion local resolver (#645) * uptake latest sdk; add ion local resolver * add back toml example * add link --- config/dev.toml | 2 +- config/{config.toml.example => kitchensink.toml} | 2 +- config/prod.toml | 2 +- config/test.toml | 2 +- .../credential_issuer_metadata.example.json | 0 doc/config/toml.md | 10 +++++++--- go.mod | 4 ++-- go.sum | 8 ++++---- internal/did/resolver.go | 3 +++ pkg/authorizationserver/oauth2.go | 2 +- pkg/authorizationserver/oauth2_test.go | 2 +- 11 files changed, 22 insertions(+), 15 deletions(-) rename config/{config.toml.example => kitchensink.toml} (98%) rename config/{ => testdata}/credential_issuer_metadata.example.json (100%) diff --git a/config/dev.toml b/config/dev.toml index a3841c907..dca1ffc4b 100644 --- a/config/dev.toml +++ b/config/dev.toml @@ -34,7 +34,7 @@ option = "bolt.db" [services.did] methods = ["key", "web"] -local_resolution_methods = ["key", "web", "pkh", "peer"] +local_resolution_methods = ["ion", "key", "web", "pkh", "peer"] universal_resolver_url = "https://dev.uniresolver.io/" universal_resolver_methods = ["ion"] batch_create_max_items = 100 diff --git a/config/config.toml.example b/config/kitchensink.toml similarity index 98% rename from config/config.toml.example rename to config/kitchensink.toml index 604708a83..7c66a722c 100644 --- a/config/config.toml.example +++ b/config/kitchensink.toml @@ -53,4 +53,4 @@ batch_create_max_items = 100 batch_create_max_items = 100 [services.webhook] -webhook_timeout = "10s" +webhook_timeout = "10s" \ No newline at end of file diff --git a/config/prod.toml b/config/prod.toml index b93ec37d6..7373790dd 100644 --- a/config/prod.toml +++ b/config/prod.toml @@ -43,7 +43,7 @@ disable_encryption = false [services.did] methods = ["key", "web", "ion"] -local_resolution_methods = ["key", "web", "pkh", "peer"] +local_resolution_methods = ["ion", "key", "web", "pkh", "peer"] universal_resolver_url = "http://uni-resolver-web:8080" universal_resolver_methods = ["ion"] ion_resolver_url = "https://ion.tbddev.org" diff --git a/config/test.toml b/config/test.toml index 919891ea4..536d0998d 100644 --- a/config/test.toml +++ b/config/test.toml @@ -45,7 +45,7 @@ disable_encryption = false [services.did] methods = ["key", "web", "ion"] -local_resolution_methods = ["key", "web", "pkh", "peer"] +local_resolution_methods = ["ion", "key", "web", "pkh", "peer"] universal_resolver_url = "http://uni-resolver-web:8080" universal_resolver_methods = ["ion"] ion_resolver_url = "https://ion.tbddev.org" diff --git a/config/credential_issuer_metadata.example.json b/config/testdata/credential_issuer_metadata.example.json similarity index 100% rename from config/credential_issuer_metadata.example.json rename to config/testdata/credential_issuer_metadata.example.json diff --git a/doc/config/toml.md b/doc/config/toml.md index 0abb04b61..eed9229a3 100644 --- a/doc/config/toml.md +++ b/doc/config/toml.md @@ -1,20 +1,24 @@ # TOML Config File + Config is managed using a [TOML](https://toml.io/en/) [file](https://github.com/TBD54566975/ssi-service/blob/main/config/config.toml). There are sets of configuration values for the server (e.g. which port to listen on), the services (e.g. which database to use), and each service. Each service may define specific configuration, such as which DID methods are enabled for the DID service. +A full config example is [provided here](../../config/kitchensink.toml). + ## Usage How it works: + 1. On startup: SSI-Service loads default values into the `SSIServiceConfig` 2. Checks for a TOML config file: - - If exists...load toml file - - If does not exist...it uses a default config defined in the code inline + - If exists...load toml file + - If does not exist...it uses a default config defined in the code inline 3. Loads the `config/.env` file and adds the env variables defined in this file to the final `SSIServiceConfig` There are a number of configuration files in this directory provided as defaults. Specifically, `config.toml`is intended to be used when the service is run as a local go process. There is another file, `compose.toml`, which is intended to be used when the service is run via docker compose. To make this switch, it's recommended that one renames the file to `config.toml` and then maintains the original `compose.toml` file as -`local.toml` or similar. +`local.toml` or similar. diff --git a/go.mod b/go.mod index 0304c4777..8a2721d78 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/BurntSushi/toml v1.3.2 - github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230804184541-a62922c45264 + github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230808183115-fc9c08eaa4f1 github.com/alicebob/miniredis/v2 v2.30.4 github.com/ardanlabs/conf v1.5.0 github.com/benbjohnson/clock v1.3.5 @@ -86,7 +86,7 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/swag v0.22.3 // indirect - github.com/go-playground/validator/v10 v10.14.1 // indirect + github.com/go-playground/validator/v10 v10.15.0 // indirect github.com/golang/glog v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect diff --git a/go.sum b/go.sum index 55129998b..2354a0ee9 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230804184541-a62922c45264 h1:5Sjk7Q8M9TNYWc3DV4SDORRxdNbFINz8JHkHCGeAnn4= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230804184541-a62922c45264/go.mod h1:mVKRjfdpgmCxPwnfQluXGkgzsFyrPsjrCvHXCJ41avQ= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230808183115-fc9c08eaa4f1 h1:xkBqbEfJ8/hRLsI7R4tL7fakgOb3XcSLECFUDFcKf3I= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230808183115-fc9c08eaa4f1/go.mod h1:zWPeE7qRviA8YBqeHONVz9OfbKT/3BusFkkzpF94Sys= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE= github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= @@ -182,8 +182,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= -github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.15.0 h1:nDU5XeOKtB3GEa+uB7GNYwhVKsgjAR7VgKoNB6ryXfw= +github.com/go-playground/validator/v10 v10.15.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= diff --git a/internal/did/resolver.go b/internal/did/resolver.go index df4bb223d..276366839 100644 --- a/internal/did/resolver.go +++ b/internal/did/resolver.go @@ -4,6 +4,7 @@ import ( "fmt" didsdk "github.com/TBD54566975/ssi-sdk/did" + "github.com/TBD54566975/ssi-sdk/did/ion" "github.com/TBD54566975/ssi-sdk/did/jwk" "github.com/TBD54566975/ssi-sdk/did/key" "github.com/TBD54566975/ssi-sdk/did/peer" @@ -48,6 +49,8 @@ func getKnownResolver(method string) (resolution.Resolver, error) { return new(peer.Resolver), nil case didsdk.JWKMethod: return new(jwk.Resolver), nil + case didsdk.IONMethod: + return new(ion.LocalResolver), nil } return nil, fmt.Errorf("unsupported method: %s", method) } diff --git a/pkg/authorizationserver/oauth2.go b/pkg/authorizationserver/oauth2.go index 973c792e8..c79cee85e 100644 --- a/pkg/authorizationserver/oauth2.go +++ b/pkg/authorizationserver/oauth2.go @@ -132,5 +132,5 @@ func loadIssuerMetadata(config *AuthConfig) (*issuance.IssuerMetadata, error) { type AuthConfig struct { Server config.ServerConfig - CredentialIssuerFile string `toml:"credential_issuer_file" conf:"default:config/credential_issuer_metadata.example.json"` + CredentialIssuerFile string `toml:"credential_issuer_file" conf:"default:config/testdata/credential_issuer_metadata.example.json"` } diff --git a/pkg/authorizationserver/oauth2_test.go b/pkg/authorizationserver/oauth2_test.go index 9b0f94ed1..77448c0ee 100644 --- a/pkg/authorizationserver/oauth2_test.go +++ b/pkg/authorizationserver/oauth2_test.go @@ -27,7 +27,7 @@ func TestMain(m *testing.M) { // Create a httptest server with the metadataHandler authServer, err := NewServer(make(chan os.Signal, 1), &AuthConfig{ - CredentialIssuerFile: "../../config/credential_issuer_metadata.example.json", + CredentialIssuerFile: "../../config/testdata/credential_issuer_metadata.example.json", }, store) if err != nil { logrus.WithError(err).Fatal("cannot create authserver")