Skip to content

Commit

Permalink
uptake latest sdk; add ion local resolver (#645)
Browse files Browse the repository at this point in the history
* uptake latest sdk; add ion local resolver

* add back toml example

* add link
  • Loading branch information
decentralgabe authored Aug 8, 2023
1 parent b72143d commit 476fbe1
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/config.toml.example → config/kitchensink.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ batch_create_max_items = 100
batch_create_max_items = 100

[services.webhook]
webhook_timeout = "10s"
webhook_timeout = "10s"
2 changes: 1 addition & 1 deletion config/prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion config/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions doc/config/toml.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
3 changes: 3 additions & 0 deletions internal/did/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion pkg/authorizationserver/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion pkg/authorizationserver/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 476fbe1

Please sign in to comment.