Skip to content

Commit

Permalink
Option to use mandatody tasks verification. Replaced signup tenants c…
Browse files Browse the repository at this point in the history
…alls to Verify function usage from linking package.
  • Loading branch information
ice-myles committed Nov 13, 2024
1 parent 9cf9a44 commit b82979a
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 80 deletions.
12 changes: 7 additions & 5 deletions application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ kyc/linking:
kyc/coinDistributionEligibility:
tenant: sunwaves
config-json-url1: https://somewhere.com/something/somebogus.json
# If urls does not match <cmd/*->hostname>/$tenant/ schema.
# tenantURLs:
# sunwaves: https://localhost:7443/
# callfluent: https://localhost:7444/
# doctorx: https://localhost:7445/
# Comment if don't need in mandarody scenarios.
mandatoryScenarios:
- join_twitter
- join_telegram
- join_cmc
- signup_callfluent
- signup_doctorx
kyc/quiz:
environment: local
enable-alerts: false
Expand Down
4 changes: 2 additions & 2 deletions cmd/eskimo-hut/eskimo.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ func (s *service) GetUserByUsername( //nolint:gocritic // False negative.
// @Router /v1r/kyc/verifyCoinDistributionEligibility/users/{userId} [GET].
func (s *service) GetPendingKYCVerificationScenarios( //nolint:gocritic // .
ctx context.Context,
req *server.Request[GetRequiredVerificationEligibilityScenariosArg, []*verificationscenarios.Scenario],
) (*server.Response[[]*verificationscenarios.Scenario], *server.Response[server.ErrorResponse]) {
req *server.Request[GetRequiredVerificationEligibilityScenariosArg, []verificationscenarios.Scenario],
) (*server.Response[[]verificationscenarios.Scenario], *server.Response[server.ErrorResponse]) {
ctx = users.ContextWithAuthorization(ctx, req.Data.Authorization) //nolint:revive // .
scenarios, err := s.verificationScenariosRepository.GetPendingVerificationScenarios(ctx, req.Data.UserID)
if err = errors.Wrapf(err, "failed to GetRequiredVerificationEligibilityScenarios for userID:%v", req.Data.UserID); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb
github.com/ice-blockchain/santa v1.168.0
github.com/ice-blockchain/santa v1.174.0
github.com/ice-blockchain/wintr v1.154.0
github.com/imroc/req/v3 v3.48.0
github.com/ip2location/ip2location-go/v9 v9.7.0
Expand All @@ -31,7 +31,7 @@ require (
require (
cel.dev/expr v0.18.0 // indirect
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go/auth v0.10.1 // indirect
cloud.google.com/go/auth v0.10.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/firestore v1.17.0 // indirect
Expand Down Expand Up @@ -103,7 +103,7 @@ require (
github.com/google/pprof v0.0.0-20241101162523-b92577c0c142 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down Expand Up @@ -188,9 +188,9 @@ require (
golang.org/x/tools v0.27.0 // indirect
google.golang.org/api v0.205.0 // indirect
google.golang.org/appengine/v2 v2.0.6 // indirect
google.golang.org/genproto v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto v0.0.0-20241113154021-e0fbfb71d213 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113154021-e0fbfb71d213 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113154021-e0fbfb71d213 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/grpc/stats/opentelemetry v0.0.0-20241028142157-ada6787961b3 // indirect
google.golang.org/protobuf v1.35.1 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cel.dev/expr v0.18.0/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U=
cloud.google.com/go/auth v0.10.1 h1:TnK46qldSfHWt2a0b/hciaiVJsmDXWy9FqyUan0uYiI=
cloud.google.com/go/auth v0.10.1/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI=
cloud.google.com/go/auth v0.10.2 h1:oKF7rgBfSHdp/kuhXtqU/tNDr0mZqhYbEh+6SiqzkKo=
cloud.google.com/go/auth v0.10.2/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI=
cloud.google.com/go/auth/oauth2adapt v0.2.5 h1:2p29+dePqsCHPP1bqDJcKj4qxRyYCcbzKpFyKGt3MTk=
cloud.google.com/go/auth/oauth2adapt v0.2.5/go.mod h1:AlmsELtlEBnaNTL7jCj8VQFLy6mbZv0s4Q7NGBeQ5E8=
cloud.google.com/go/compute/metadata v0.5.2 h1:UxK4uu/Tn+I3p2dYWTfiX4wva7aYlKixAHn3fyqngqo=
Expand Down Expand Up @@ -238,8 +238,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw=
github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA=
github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s=
github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A=
github.com/googleapis/gax-go/v2 v2.14.0 h1:f+jMrjBPl+DL9nI4IQzLUxMq7XrAqFYB7hBPqMNIe8o=
github.com/googleapis/gax-go/v2 v2.14.0/go.mod h1:lhBCnjdLrWRaPvLWhmc8IS24m9mr07qSYnHncrgo+zk=
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248=
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand All @@ -251,8 +251,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8=
github.com/ice-blockchain/santa v1.168.0 h1:7FQp239sV02w7EejDr4j74Q9OTikzdZEtPcWtR5K8XE=
github.com/ice-blockchain/santa v1.168.0/go.mod h1:xXI7k0+QSgwxvZ8IgPDddmnJxpTJO3IG7Xa7v1E7RGs=
github.com/ice-blockchain/santa v1.174.0 h1:MUKMSHdmfkCqPxHf0mje6SqMuGH7y8HmmbSWEHsySmE=
github.com/ice-blockchain/santa v1.174.0/go.mod h1:wA5bA3h6zz0kYt6s3aJ9dDsvWt8SdxYwAUrOJQXpC1E=
github.com/ice-blockchain/wintr v1.154.0 h1:yZSQtAEwGHTSmJ5pXjX0tpui1TNnG615QfpBkhY99a4=
github.com/ice-blockchain/wintr v1.154.0/go.mod h1:DoUn66XJGzPzfCZTsHyMjfgj2aVLGvjqDSuKj2pa3KE=
github.com/imroc/req/v3 v3.48.0 h1:IYuMGetuwLzOOTzDCquDqs912WNwpsPK0TBXWPIvoqg=
Expand Down Expand Up @@ -574,12 +574,12 @@ google.golang.org/appengine/v2 v2.0.6/go.mod h1:WoEXGoXNfa0mLvaH5sV3ZSGXwVmy8yf7
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20241104194629-dd2ea8efbc28 h1:KJjNNclfpIkVqrZlTWcgOOaVQ00LdBnoEaRfkUx760s=
google.golang.org/genproto v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:mt9/MofW7AWQ+Gy179ChOnvmJatV8YHUmrcedo9CIFI=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1:XVhgTWWV3kGQlwJHR3upFWZeTsei6Oks1apkZSeonIE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/genproto v0.0.0-20241113154021-e0fbfb71d213 h1:aK1CSq3+WIXZj6XcWhK0fAb303nF8sta2eca0DSARwQ=
google.golang.org/genproto v0.0.0-20241113154021-e0fbfb71d213/go.mod h1:Q5m6g8b5KaFFzsQFIGdJkSJDGeJiybVenoYFMMa3ohI=
google.golang.org/genproto/googleapis/api v0.0.0-20241113154021-e0fbfb71d213 h1:cNftAhx0Q32f3Fz2+BLargfsMD6pGINE+/mUZneTMyk=
google.golang.org/genproto/googleapis/api v0.0.0-20241113154021-e0fbfb71d213/go.mod h1:Yo94eF2nj7igQt+TiJ49KxjIH8ndLYPZMIRSiRcEbg0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113154021-e0fbfb71d213 h1:L+WcQXqkyf5MX6g7AudgYEuJjmYbqSRkTmJqGfAPw+Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113154021-e0fbfb71d213/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
Expand Down
4 changes: 2 additions & 2 deletions kyc/linking/linking.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (l *linker) Get(ctx context.Context, userID UserID) (allLinkedProfiles Link
}

func (l *linker) verifyToken(ctx context.Context, userID, tenant, token string) (remoteID UserID, hasFaceResult bool, err error) {
usr, err := FetchTokenData(ctx, tenant, token, l.host, l.cfg.TenantURLs)
usr, err := fetchTokenData(ctx, tenant, token, l.host, l.cfg.TenantURLs)
if err != nil {
if errors.Is(err, ErrRemoteUserNotFound) {
return "", false, errors.Wrapf(ErrNotOwnRemoteUser, "token is not belong to %v", userID)
Expand All @@ -156,7 +156,7 @@ func (l *linker) verifyToken(ctx context.Context, userID, tenant, token string)
}

//nolint:funlen // Single http call.
func FetchTokenData(ctx context.Context, tenant, token, host string, tenantURLs map[Tenant]string) (*users.User, error) {
func fetchTokenData(ctx context.Context, tenant, token, host string, tenantURLs map[Tenant]string) (*users.User, error) {
tok, err := server.Auth(ctx).ParseToken(token, false)
if err != nil {
return nil, errors.Wrapf(err, "invalid token passed")
Expand Down
17 changes: 10 additions & 7 deletions kyc/verification_scenarios/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (
CoinDistributionScenarioSignUpSauces TenantScenario = "signup_sauces"
CoinDistributionScenarioSignUpDoctorx TenantScenario = "signup_doctorx"
CoinDistributionScenarioSignUpTokero TenantScenario = "signup_tokero"

singUpPrefix = "signup"
)

// .
Expand All @@ -43,12 +45,12 @@ var (

type (
Tenant string
Token string
Scenario string
TenantScenario string
Token = string
TenantScenario = string
Repository interface {
VerifyScenarios(ctx context.Context, metadata *VerificationMetadata) error
GetPendingVerificationScenarios(ctx context.Context, userID string) ([]*Scenario, error)
GetPendingVerificationScenarios(ctx context.Context, userID string) ([]Scenario, error)
}
UserRepository interface {
io.Closer
Expand Down Expand Up @@ -101,9 +103,10 @@ type (
host string
}
config struct {
TenantURLs map[string]string `yaml:"tenantURLs" mapstructure:"tenantURLs"` //nolint:tagliatelle // .
kycConfigJSON1 *atomic.Pointer[social.KycConfigJSON]
Tenant string `yaml:"tenant" mapstructure:"tenant"`
ConfigJSONURL1 string `yaml:"config-json-url1" mapstructure:"config-json-url1"` //nolint:tagliatelle // .
TenantURLs map[string]string `yaml:"tenantURLs" mapstructure:"tenantURLs"` //nolint:tagliatelle // .
kycConfigJSON1 *atomic.Pointer[social.KycConfigJSON]
Tenant string `yaml:"tenant" mapstructure:"tenant"`
ConfigJSONURL1 string `yaml:"config-json-url1" mapstructure:"config-json-url1"` //nolint:tagliatelle // .
MandatoryScenarios []Scenario `yaml:"mandatoryScenarios" mapstructure:"mandatoryScenarios"` //nolint:tagliatelle // .
}
)
Loading

0 comments on commit b82979a

Please sign in to comment.