Skip to content

Commit

Permalink
Merge pull request #4177 from nickmango/feature/doc-webhook-payload
Browse files Browse the repository at this point in the history
Feature/Docsign Payload
  • Loading branch information
nickmango authored Nov 20, 2023
2 parents b38edd6 + c3e5a6b commit 8ef3e8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cla-backend-go/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func server(localMode bool) http.Handler {
v2GithubActivityService := v2GithubActivity.NewService(gitV1Repository, githubOrganizationsRepo, eventsService, autoEnableService, emailService)

v2ClaGroupService := cla_groups.NewService(v1ProjectService, templateService, v1ProjectClaGroupRepo, v1ClaManagerService, v1SignaturesService, metricsRepo, gerritService, v1RepositoriesService, eventsService)
v2SignService := sign.NewService(configFile.ClaV1ApiURL, v1CompanyRepo, v1CLAGroupRepo, v1ProjectClaGroupRepo, v1CompanyService, v2ClaGroupService, configFile.DocuSignPrivateKey, usersService, v1SignaturesService, storeRepository, v1RepositoriesService, githubOrganizationsService, gitlabOrganizationsService)
v2SignService := sign.NewService(configFile.ClaAPIV4Base, v1CompanyRepo, v1CLAGroupRepo, v1ProjectClaGroupRepo, v1CompanyService, v2ClaGroupService, configFile.DocuSignPrivateKey, usersService, v1SignaturesService, storeRepository, v1RepositoriesService, githubOrganizationsService, gitlabOrganizationsService)

sessionStore, err := dynastore.New(dynastore.Path("/"), dynastore.HTTPOnly(), dynastore.TableName(configFile.SessionStoreTableName), dynastore.DynamoDB(dynamodb.New(awsSession)))
if err != nil {
Expand Down
12 changes: 8 additions & 4 deletions cla-backend-go/swagger/cla.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4179,7 +4179,8 @@ paths:
in: body
required: true
schema:
type: string
type: object
additionalProperties: true
responses:
'200':
description: Successfully received and processed the callback data.
Expand All @@ -4204,7 +4205,8 @@ paths:
in: body
required: true
schema:
type: string
type: object
additionalProperties: true
responses:
'200':
description: Successfully received and processed the Gerrit callback data.
Expand Down Expand Up @@ -4233,7 +4235,8 @@ paths:
in: body
required: true
schema:
type: string
type: object
additionalProperties: true
responses:
'200':
description: Successfully received and processed the callback data for corporate signatures.
Expand Down Expand Up @@ -4270,7 +4273,8 @@ paths:
in: body
required: true
schema:
type: string
type: object
additionalProperties: true
responses:
'200':
description: Callback data for GitLab successfully received and processed.
Expand Down
2 changes: 2 additions & 0 deletions cla-backend-go/v2/sign/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ func Configure(api *operations.EasyclaAPI, service Service, userService users.Se
return sign.NewIclaCallbackGithubBadRequest()
}

log.WithFields(f).Debugf("body: %+v", payload)

err := service.SignedIndividualCallbackGithub(ctx, payload, params.InstallationID, params.ChangeRequestID, params.GithubRepositoryID)
if err != nil {
return sign.NewIclaCallbackGithubBadRequest()
Expand Down
14 changes: 7 additions & 7 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Service interface {

// service
type service struct {
ClaV1ApiURL string
ClaV4ApiURL string
companyRepo company.IRepository
projectRepo ProjectRepo
projectClaGroupsRepo projects_cla_groups.Repository
Expand All @@ -101,7 +101,7 @@ type service struct {
func NewService(apiURL string, compRepo company.IRepository, projectRepo ProjectRepo, pcgRepo projects_cla_groups.Repository, compService company.IService, claGroupService cla_groups.Service, docsignPrivateKey string, userService users.Service, signatureService signatures.SignatureService, storeRepository store.Repository,
repositoryService repositories.Service, githubOrgService github_organizations.Service, gitlabOrgService gitlab_organizations.ServiceInterface) Service {
return &service{
ClaV1ApiURL: apiURL,
ClaV4ApiURL: apiURL,
companyRepo: compRepo,
projectRepo: projectRepo,
projectClaGroupsRepo: pcgRepo,
Expand Down Expand Up @@ -303,7 +303,7 @@ func (s *service) RequestCorporateSignature(ctx context.Context, lfUsername stri
}
}

signature, err := s.requestCorporateSignature(ctx, s.ClaV1ApiURL, &requestCorporateSignatureInput{
signature, err := s.requestCorporateSignature(ctx, s.ClaV4ApiURL, &requestCorporateSignatureInput{
ProjectID: proj.ProjectID,
CompanyID: comp.CompanyID,
SigningEntityName: input.SigningEntityName,
Expand Down Expand Up @@ -338,7 +338,7 @@ func (s *service) RequestCorporateSignature(ctx context.Context, lfUsername stri
}

func (s *service) getCorporateSignatureCallbackUrl(companyId, projectId string) string {
return fmt.Sprintf("%s/v2/signed/corporate/%s/%s", s.ClaV1ApiURL, companyId, projectId)
return fmt.Sprintf("%s/v2/signed/corporate/%s/%s", s.ClaV4ApiURL, companyId, projectId)
}

func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []byte, installationID, changeRequestID, repositoryID string) error {
Expand Down Expand Up @@ -736,7 +736,7 @@ func (s *service) getIndividualSignatureCallbackURLGitlab(ctx context.Context, u
return "", err
}

return fmt.Sprintf("%s/v2/signed/gitlab/individual/%s/%s/%s/%s", s.ClaV1ApiURL, userID, gitlabOrg.OrganizationID, repositoryID, mergeRequestID), nil
return fmt.Sprintf("%s/v4/signed/gitlab/individual/%s/%s/%s/%s", s.ClaV4ApiURL, userID, gitlabOrg.OrganizationID, repositoryID, mergeRequestID), nil

}

Expand Down Expand Up @@ -796,7 +796,7 @@ func (s *service) getIndividualSignatureCallbackURL(ctx context.Context, userID
return "", err
}

return fmt.Sprintf("%s/v2/signed/individual/%d/%s/%s", s.ClaV1ApiURL, installationId, repositoryID, pullRequestID), nil
return fmt.Sprintf("%s/v2/signed/individual/%d/%s/%s", s.ClaV4ApiURL, installationId, repositoryID, pullRequestID), nil
}

//nolint:gocyclo
Expand Down Expand Up @@ -1101,7 +1101,7 @@ func (s *service) populateSignURL(ctx context.Context,
return "", errors.New("no envelope recipients found")
}
recipient := recipients[0]
returnURL := fmt.Sprintf("%s/v2/return-url/%s", s.ClaV1ApiURL, recipient.ClientUserId)
returnURL := fmt.Sprintf("%s/v2/return-url/%s", s.ClaV4ApiURL, recipient.ClientUserId)

log.WithFields(f).Debugf("generating signature sign_url, using return-url as: %s", returnURL)
signURL, signErr := s.GetSignURL(signer.Email, signer.RecipientId, signer.Name, signer.ClientUserId, envelopeResponse.EnvelopeId, returnURL)
Expand Down

0 comments on commit 8ef3e8a

Please sign in to comment.