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

Feat: expires time #80

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 46 additions & 6 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,36 @@ func (v *Verifier) SetupJWSPacker(didResolver packers.DIDResolverHandlerFunc) er
return v.packageManager.RegisterPackers(jwsPacker)
}

// WithExpiresTime sets the expires time message option.
func WithExpiresTime(expiresTime *time.Time) AuthorizationRequestMessageOpts {
return func(v *AuthorizationRequestMessageConfig) {
v.ExpiresTime = expiresTime
}
}

// AuthorizationRequestMessageOpts sets options.
type AuthorizationRequestMessageOpts func(v *AuthorizationRequestMessageConfig)

// AuthorizationRequestMessageConfig - configuration for CreateAuthorizationRequest.
type AuthorizationRequestMessageConfig struct {
ExpiresTime *time.Time
}

// CreateAuthorizationRequest creates new authorization request message
// sender - client identifier
// reason - describes purpose of request
// callbackURL - url for authorization response
func CreateAuthorizationRequest(reason, sender, callbackURL string) protocol.AuthorizationRequestMessage {
return CreateAuthorizationRequestWithMessage(reason, "", sender, callbackURL)
func CreateAuthorizationRequest(reason, sender, callbackURL string, opts ...AuthorizationRequestMessageOpts) protocol.AuthorizationRequestMessage {
return CreateAuthorizationRequestWithMessage(reason, "", sender, callbackURL, opts...)
}

// CreateAuthorizationRequestWithMessage creates new authorization request with message for signing with jwz
func CreateAuthorizationRequestWithMessage(reason, message, sender,
callbackURL string) protocol.AuthorizationRequestMessage {
callbackURL string, opts ...AuthorizationRequestMessageOpts) protocol.AuthorizationRequestMessage {
cfg := AuthorizationRequestMessageConfig{}
for _, o := range opts {
o(&cfg)
}
var request protocol.AuthorizationRequestMessage

request.Typ = packers.MediaTypePlainMessage
Expand All @@ -270,7 +289,14 @@ func CreateAuthorizationRequestWithMessage(reason, message, sender,
Scope: []protocol.ZeroKnowledgeProofRequest{},
}
request.From = sender

createTime := time.Now().Unix()
request.CreatedTime = &createTime
var expiresTime *int64
if cfg.ExpiresTime != nil {
expiresTimeUnix := cfg.ExpiresTime.Unix()
expiresTime = &expiresTimeUnix
}
request.ExpiresTime = expiresTime
vmidyllic marked this conversation as resolved.
Show resolved Hide resolved
return request
}

Expand Down Expand Up @@ -392,7 +418,14 @@ func (v *Verifier) VerifyAuthResponse(
request protocol.AuthorizationRequestMessage,
opts ...pubsignals.VerifyOpt,
) error {

cfg := pubsignals.VerifyConfig{}
for _, o := range opts {
o(&cfg)
}
if (cfg.AllowExpiredMessages == nil || !*cfg.AllowExpiredMessages) &&
response.ExpiresTime != nil && time.Now().After(time.Unix(*response.ExpiresTime, 0)) {
return errors.New("Authorization response message is expired")
}
if request.Body.Message != response.Body.Message {
return errors.Errorf("message for request id %v was not presented in the response", request.ID)
}
Expand Down Expand Up @@ -559,7 +592,14 @@ func (v *Verifier) FullVerify(
request protocol.AuthorizationRequestMessage,
opts ...pubsignals.VerifyOpt, // TODO(illia-korotia): is ok have common option for VerifyJWZ and VerifyAuthResponse?
) (*protocol.AuthorizationResponseMessage, error) {

cfg := pubsignals.VerifyConfig{}
for _, o := range opts {
o(&cfg)
}
if (cfg.AllowExpiredMessages == nil || !*cfg.AllowExpiredMessages) &&
request.ExpiresTime != nil && time.Now().After(time.Unix(*request.ExpiresTime, 0)) {
return nil, errors.New("Authorization request message is expired")
}
vmidyllic marked this conversation as resolved.
Show resolved Hide resolved
msg, _, err := v.packageManager.Unpack([]byte(token))
if err != nil {
return nil, err
Expand Down
30 changes: 30 additions & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1225,3 +1225,33 @@ func TestFullVerifyLinkedProofsVerification(t *testing.T) {
require.NotNil(t, returnMsg)
schemaLoader.assert(t)
}

func TestVerifier_FullVerify_ExpiredMessage(t *testing.T) {
verifierID := "did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL"
callbackURL := "https://test.com/callback"
reason := "age verification"
expiredTime := time.Now().Add(-time.Hour)
request := CreateAuthorizationRequestWithMessage(reason, "", verifierID, callbackURL, WithExpiresTime(&expiredTime))
request.ID = "28494007-9c49-4f1a-9694-7700c08865bf"
request.ThreadID = "ee92ab12-2671-457e-aa5e-8158c205a985" // because it's used in the response
token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0SWQiXSwidHlwIjoiYXBwbGljYXRpb24vaWRlbjMtemtwLWpzb24ifQ.eyJpZCI6IjljMGY5NjIzLWM1NmMtNDEwNC04ODk2LWVjMjgyYTNiMmExNyIsInR5cCI6ImFwcGxpY2F0aW9uL2lkZW4zY29tbS1wbGFpbi1qc29uIiwidHlwZSI6Imh0dHBzOi8vaWRlbjMtY29tbXVuaWNhdGlvbi5pby9hdXRob3JpemF0aW9uLzEuMC9yZXNwb25zZSIsInRoaWQiOiI3ZjM4YTE5My0wOTE4LTRhNDgtOWZhYy0zNmFkZmRiOGI1NDIiLCJmcm9tIjoiZGlkOnBvbHlnb25pZDpwb2x5Z29uOm11bWJhaToycVBETFhEYVUxeGExRVJUYjFYS0JmUENCM28yd0E0NnE0OW5laVhXd1kiLCJ0byI6ImRpZDpwb2x5Z29uaWQ6cG9seWdvbjptdW1iYWk6MnFKNjg5a3BvSnhjU3pCNXNBRkp0UHNTQlNySEY1ZHE3MjJCSE1xVVJMIiwiYm9keSI6eyJkaWRfZG9jIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy9ucy9kaWQvdjEiXSwiaWQiOiJkaWQ6cG9seWdvbmlkOnBvbHlnb246bXVtYmFpOjJxUERMWERhVTF4YTFFUlRiMVhLQmZQQ0IzbzJ3QTQ2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wMDE1NjU1MjQzMDAwNCIsIjEyNjkyNzA3NDA3MTczMDg0OTM5NzQ1ODU5NzE0ODMxNDYyMDQ1ODg5NDA4NTk4NTI3MjU0ODA3NzkwNDk0NDY2Mjc5Njg3ODU5MjQ3IiwiMSJdLCJwcm90b2NvbCI6Imdyb3RoMTYiLCJjdXJ2ZSI6ImJuMTI4In0sInB1Yl9zaWduYWxzIjpbIjI3MTUyNjc2OTg3MTI4NTQyMDY2ODA4NTkxOTk4NTczMDAwMzcwNDM2NDY0NzIyNTE5NTEzMzQ4ODkxMDQ5NjQ0ODEzNzE4MDE4IiwiMTIxODQ5NzQwNzE0Mjc3NjgzNTIwMjcwMDM4NzgzMTkzMzgyNDkzODM4NDYxNjQ3MzAyMDQ1MDUzMjY5NTM1NTA2NDczOTExNzg4MDAiLCI4NzU2MDYwMjA1MDg2ODAzMzM1MjUyMzE5NzQ4NzQ4MzU0NzYxOTYxODE0MDEyNzI1NDk5ODczMzgyOTg4MDU2NDE4NjgwNjI4NjE5Il19`
authInstance, err := NewVerifier(verificationKeyloader, stateResolvers)
require.NoError(t, err)
_, err = authInstance.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay), pubsignals.WithAllowExpiredMessages(false))
require.Error(t, err, errors.New("Authorization request message is expired"))
}

func TestVerifier_FullVerify_ExpiredMessageWithAllowExpired(t *testing.T) {
verifierID := "did:polygonid:polygon:mumbai:2qJ689kpoJxcSzB5sAFJtPsSBSrHF5dq722BHMqURL"
callbackURL := "https://test.com/callback"
reason := "age verification"
expiredTime := time.Now().Add(-time.Hour)
request := CreateAuthorizationRequestWithMessage(reason, "", verifierID, callbackURL, WithExpiresTime(&expiredTime))
request.ID = "28494007-9c49-4f1a-9694-7700c08865bf"
request.ThreadID = "ee92ab12-2671-457e-aa5e-8158c205a985" // because it's used in the response
token := `eyJhbGciOiJncm90aDE2IiwiY2lyY3VpdElkIjoiYXV0aFYyIiwiY3JpdCI6WyJjaXJjdWl0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4NzgzMTkzMzgyNDkzODM4NDYxNjQ3MzAyMDQ1MDUzMjY5NTM1NTA2NDczOTExNzg4MDAiLCI4NzU2MDYwMjA1MDg2ODAzMzM1MjUyMzE5NzQ4NzQ4MzU0NzYxOTYxODE0MDEyNzI1NDk5ODczMzgyOTg4MDU2NDE4NjgwNjI4NjE5Il19`
authInstance, err := NewVerifier(verificationKeyloader, stateResolvers)
require.NoError(t, err)
_, err = authInstance.FullVerify(context.Background(), token, request, pubsignals.WithAcceptedProofGenerationDelay(proofGenerationDelay), pubsignals.WithAllowExpiredMessages(true))
require.NoError(t, err)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/iden3/go-rapidsnark/types v0.0.3
github.com/iden3/go-rapidsnark/verifier v0.0.5
github.com/iden3/go-schema-processor/v2 v2.5.0
github.com/iden3/iden3comm/v2 v2.8.1
github.com/iden3/iden3comm/v2 v2.8.2
github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e
github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk=
github.com/iden3/go-schema-processor/v2 v2.5.0 h1:MX84oFb9kYq0ntKiU4DrPPaRgCDUCKlurtHB6nvPPAs=
github.com/iden3/go-schema-processor/v2 v2.5.0/go.mod h1:hMqYi4lKOzEGkmCRks/r4Crj8H4G8YaTt8H4jZHzX9Y=
github.com/iden3/iden3comm/v2 v2.8.1 h1:SjDXYS2O9jfpXNUzSdOBRTs+EjFKPkKOz4/IFkaOfXQ=
github.com/iden3/iden3comm/v2 v2.8.1/go.mod h1:l8t+BkbHU3ri7kiExZYc4CTY6erkzkcBbYXw416nwhA=
github.com/iden3/iden3comm/v2 v2.8.2 h1:hDlu/T7PWTiMtoliMTHpMv5F5nyxE3p3JWbo1c3XjvY=
github.com/iden3/iden3comm/v2 v2.8.2/go.mod h1:l8t+BkbHU3ri7kiExZYc4CTY6erkzkcBbYXw416nwhA=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
8 changes: 8 additions & 0 deletions pubsignals/verifyopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ func WithAcceptedProofGenerationDelay(duration time.Duration) VerifyOpt {
}
}

// WithAllowExpiredMessages sets the allow expired messages option.
func WithAllowExpiredMessages(allowExpiredMessages bool) VerifyOpt {
return func(v *VerifyConfig) {
v.AllowExpiredMessages = &allowExpiredMessages
}
}

// VerifyOpt sets options.
type VerifyOpt func(v *VerifyConfig)

Expand All @@ -32,6 +39,7 @@ type VerifyConfig struct {
// is the period of time that a revoked state remains valid.
AcceptedStateTransitionDelay time.Duration
AcceptedProofGenerationDelay time.Duration
AllowExpiredMessages *bool
}

// ParamNameVerifierDID is a verifier did - specific circuit param for V3, but can be utilized by other circuits
Expand Down
Loading