Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M2m #26

Merged
merged 73 commits into from
Dec 18, 2023
Merged

M2m #26

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
9572d48
add more token stuff
wistefan Nov 24, 2023
3b53431
add
wistefan Nov 27, 2023
7ec5bf2
temp
wistefan Nov 27, 2023
721ab47
Merge branch 'main' into m2m
wistefan Nov 27, 2023
11415de
implement m2m token
wistefan Nov 27, 2023
dc679f8
add vp proof
wistefan Nov 28, 2023
11723ac
logging
wistefan Nov 28, 2023
b1e7bd6
add 401
wistefan Nov 28, 2023
95c5e88
more logging
wistefan Nov 28, 2023
7f796df
more
wistefan Nov 28, 2023
239ed2b
more
wistefan Nov 28, 2023
66abefd
more
wistefan Nov 28, 2023
de46dc0
try
wistefan Nov 28, 2023
8323ce2
and more
wistefan Nov 28, 2023
f1cee6e
try to change again
wistefan Nov 28, 2023
dd4234d
logging
wistefan Nov 28, 2023
4300ca5
try more
wistefan Nov 28, 2023
97cde0b
use ctx
wistefan Nov 28, 2023
30a0ed3
updates
wistefan Nov 29, 2023
6f6ec0e
next
wistefan Nov 29, 2023
3ef2a36
try to disable
wistefan Nov 30, 2023
affbc66
yet another try
wistefan Nov 30, 2023
e635fcc
try
wistefan Dec 1, 2023
6876d95
cleaning
wistefan Dec 1, 2023
d892c26
update lib
wistefan Dec 4, 2023
236374f
fix docker
wistefan Dec 4, 2023
494e677
bytes
wistefan Dec 4, 2023
873aa04
cred
wistefan Dec 4, 2023
9516d86
remove validation
wistefan Dec 4, 2023
2b76ef1
jwt
wistefan Dec 4, 2023
e666201
try rsa
wistefan Dec 4, 2023
fc5eb46
try
wistefan Dec 4, 2023
7290efd
try another
wistefan Dec 4, 2023
96e74ec
rsa type
wistefan Dec 4, 2023
f7a9779
try
wistefan Dec 4, 2023
65a0d9c
try to add
wistefan Dec 4, 2023
8c433e8
and another key
wistefan Dec 4, 2023
63df51b
the othere
wistefan Dec 4, 2023
1852174
return the metadata
wistefan Dec 5, 2023
52faac9
get token
wistefan Dec 5, 2023
191e35e
use the host from config
wistefan Dec 5, 2023
25f4d8c
print req
wistefan Dec 5, 2023
369833c
from config
wistefan Dec 5, 2023
4169521
logging
wistefan Dec 5, 2023
286b24b
logging
wistefan Dec 5, 2023
ec021e7
token
wistefan Dec 5, 2023
2e03cac
logging
wistefan Dec 5, 2023
99cb874
string
wistefan Dec 5, 2023
6159cbc
to string
wistefan Dec 5, 2023
976fc93
more logging
wistefan Dec 5, 2023
0794289
m
wistefan Dec 5, 2023
62c40c9
cred
wistefan Dec 5, 2023
4351d44
no validation
wistefan Dec 5, 2023
292ca6e
disable
wistefan Dec 5, 2023
e18a6e2
parse
wistefan Dec 5, 2023
988b933
add client id
wistefan Dec 5, 2023
8bf715b
header
wistefan Dec 5, 2023
b71ecf6
config
wistefan Dec 5, 2023
9606dea
use the value
wistefan Dec 5, 2023
ad98b30
logging
wistefan Dec 5, 2023
43a316e
fix check
wistefan Dec 5, 2023
c15a2ea
fix tests
wistefan Dec 6, 2023
4643ead
update ga
wistefan Dec 6, 2023
8c36d06
add tests
wistefan Dec 6, 2023
43972db
tests
wistefan Dec 7, 2023
e293c44
clean logging
wistefan Dec 7, 2023
6b7c32c
clean up
wistefan Dec 7, 2023
4723a12
more cleanup
wistefan Dec 7, 2023
b2ef3ab
more cleaning
wistefan Dec 7, 2023
194bcb6
add test
wistefan Dec 7, 2023
a92e653
typo
wistefan Dec 7, 2023
68fe0dd
cleaning
wistefan Dec 7, 2023
c72d5cd
Merge branch 'main' into m2m
wistefan Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.21

- name: Install coveralls dependencies
run: |
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine AS build
FROM golang:1.21-alpine AS build

WORKDIR /go/src/app
COPY ./ ./
Expand All @@ -8,9 +8,10 @@ RUN apk add build-base
RUN go get -d -v ./...
RUN go build -v .

FROM golang:1.19-alpine
FROM golang:1.21-alpine

WORKDIR /go/src/app

COPY --from=build /go/src/app/views /go/src/app/views
COPY --from=build /go/src/app/VCVerifier /go/src/app/VCVerifier
COPY --from=build /go/src/app/server.yaml /go/src/app/server.yaml
Expand Down
13 changes: 13 additions & 0 deletions common/clock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package common

import "time"

type Clock interface {
Now() time.Time
}

type RealClock struct{}

func (RealClock) Now() time.Time {
return time.Now()
}
21 changes: 21 additions & 0 deletions common/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package common

const TYPE_CODE = "authorization_code"
const TYPE_VP_TOKEN = "vp_token"

type OpenIDProviderMetadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
PresentationDefinitionEndpoint string `json:"presentation_definition_endpoint,omitempty"`
JwksUri string `json:"jwks_uri"`
ScopesSupported []string `json:"scopes_supported"`
ResponseTypesSupported []string `json:"response_types_supported"`
ResponseModeSupported []string `json:"response_mode_supported,omitempty"`
GrantTypesSupported []string `json:"grant_types_supported,omitempty"`
SubjectTypesSupported []string `json:"subject_types_supported"`
IdTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported"`
RequestObjectSigningAlgValuesSupported []string `json:"request_object_signing_alg_values_supported,omitempty"`
RequestParameterSupported bool `json:"request_parameter_supported,omitempty"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"`
}
16 changes: 16 additions & 0 deletions common/tokenSigner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package common

import (
"github.com/lestrrat-go/jwx/jwa"
"github.com/lestrrat-go/jwx/jwt"
)

type TokenSigner interface {
Sign(t jwt.Token, alg jwa.SignatureAlgorithm, key interface{}, options ...jwt.SignOption) ([]byte, error)
}

type JwtTokenSigner struct{}

func (JwtTokenSigner) Sign(t jwt.Token, alg jwa.SignatureAlgorithm, key interface{}, options ...jwt.SignOption) ([]byte, error) {
return jwt.Sign(t, alg, key, options...)
}
21 changes: 21 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Configuration struct {
SSIKit SSIKit `mapstructure:"ssiKit"`
Logging Logging `mapstructure:"logging"`
ConfigRepo ConfigRepo `mapstructure:"configRepo"`
M2M M2M `mapstructure:"m2m"`
}

// configuration to be used by the ssiKit configuration
Expand All @@ -19,6 +20,8 @@ type SSIKit struct {

// general configuration to run the application
type Server struct {
// host name of the verifier
Host string `mapstructure:"host"`
// port to bind the server
Port int `mapstructure:"port" default:"8080"`
// directory to read the template(s) from
Expand All @@ -27,6 +30,24 @@ type Server struct {
StaticDir string `mapstructure:"staticDir" default:"views/static/"`
}

// configuration for M2M interaction
type M2M struct {
// auth enabled for M2M interactions
AuthEnabled bool `mapstructure:"authEnabled"`
// path to the signing key(in pem format)
KeyPath string `mapstructure:"keyPath"`
// path to the credential to be used for auth
CredentialPath string `mapstructure:"credentialPath"`
// id of the verifier when retrieving tokens
ClientId string `mapstructure:"clientId"`
// verification method to be provided for the ld-proof
VerificationMethod string `mapstructure:"verificationMethod" default:"JsonWebKey2020"`
// signature type to be provided for the ld-proof
SignatureType string `mapstructure:"signatureType" default:"JsonWebSignature2020"`
// type of the provided key
KeyType string `mapstructure:"keyType" default:"RSAPS256"`
}

// logging config
type Logging struct {
// loglevel to be used - can be DEBUG, INFO, WARN or ERROR
Expand Down
2 changes: 2 additions & 0 deletions config/data/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ verifier:
ssiKit:
auditorURL: http://waltid:7003

m2m:
authEnabled: false
configRepo:
services:
- id: testService
Expand Down
6 changes: 4 additions & 2 deletions config/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func Test_ReadConfig(t *testing.T) {
Id: "testService",
DefaultOidcScope: "someScope",
ServiceScopes: map[string][]Credential{
"someScope": []Credential{
Credential{
"someScope": {
{
Type: "VerifiableCredential",
TrustedParticipantsLists: []string{"https://tir-pdc.gaia-x.fiware.dev"},
TrustedIssuersLists: []string{"https://til-pdc.gaia-x.fiware.dev"},
Expand All @@ -70,6 +70,7 @@ func Test_ReadConfig(t *testing.T) {
},
},
},
M2M: M2M{AuthEnabled: false, VerificationMethod: "JsonWebKey2020", SignatureType: "JsonWebSignature2020", KeyType: "RSAPS256"},
},
false,
}, {
Expand All @@ -92,6 +93,7 @@ func Test_ReadConfig(t *testing.T) {
LogRequests: true,
PathsToSkip: nil,
},
M2M: M2M{AuthEnabled: false, VerificationMethod: "JsonWebKey2020", SignatureType: "JsonWebSignature2020", KeyType: "RSAPS256"},
},
false,
},
Expand Down
63 changes: 47 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,78 +1,109 @@
module github.com/fiware/VCVerifier

go 1.19
go 1.21

require (
github.com/bxcodec/httpcache v1.0.0-beta.3
github.com/deepmap/oapi-codegen v1.12.3
github.com/foolin/goview v0.3.0
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.0
github.com/gin-gonic/gin v1.9.1
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.0
github.com/gookit/config/v2 v2.2.1
github.com/hellofresh/health-go/v5 v5.0.0
github.com/lestrrat-go/jwx v1.2.25
github.com/mitchellh/mapstructure v1.5.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/stretchr/testify v1.8.2
github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f
github.com/stretchr/testify v1.8.4
github.com/trustbloc/did-go v1.1.0
github.com/trustbloc/kms-go v1.1.0
github.com/trustbloc/vc-go v1.1.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
)

require (
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da // indirect
github.com/VictoriaMetrics/fastcache v1.5.7 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/bxcodec/gotcha v1.0.0-beta.8 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-jose/go-jose/v3 v3.0.1-0.20221117193127-916db76e8214 // indirect
github.com/goccy/go-yaml v1.10.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/tink/go v1.7.0 // indirect
github.com/gookit/color v1.5.2 // indirect
github.com/gookit/goutil v0.6.6 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/teserakt-io/golang-ed25519 v0.0.0-20210104091850-3888c087a4c8 // indirect
github.com/tidwall/gjson v1.14.3 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/sjson v1.1.4 // indirect
github.com/trustbloc/bbs-signature-go v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.opentelemetry.io/otel v1.10.0 // indirect
go.opentelemetry.io/otel/trace v1.10.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
github.com/bytedance/sonic v1.8.5 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/fiware/dsba-pdp v0.0.0-20230215083849-cf2b4c3daacf
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.1 // indirect
github.com/goccy/go-json v0.10.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/penglongli/gin-metrics v0.1.10
github.com/procyon-projects/chrono v1.1.2
github.com/sirupsen/logrus v1.9.3
Expand All @@ -81,10 +112,10 @@ require (
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/valyala/fasttemplate v1.2.2
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading