Skip to content

Commit

Permalink
Bug/Gitlab Sign Flow
Browse files Browse the repository at this point in the history
- Resolved issue on fetching Gitlab org using external ID
- Updated Gitlab callback endpoint

Signed-off-by: Harold Wanyama <hwanyama@contractor.linuxfoundation.org>
  • Loading branch information
nickmango committed Jan 18, 2024
1 parent 4a7dece commit b187465
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 49 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.ClaAPIV4Base, configFile.ClaV1ApiURL, v1CompanyRepo, v1CLAGroupRepo, v1ProjectClaGroupRepo, v1CompanyService, v2ClaGroupService, configFile.DocuSignPrivateKey, usersService, v1SignaturesService, storeRepository, v1RepositoriesService, githubOrganizationsService, gitlabOrganizationsService, configFile.CLALandingPage, configFile.CLALogoURL, emailService, eventsService)
v2SignService := sign.NewService(configFile.ClaAPIV4Base, configFile.ClaV1ApiURL, v1CompanyRepo, v1CLAGroupRepo, v1ProjectClaGroupRepo, v1CompanyService, v2ClaGroupService, configFile.DocuSignPrivateKey, usersService, v1SignaturesService, storeRepository, v1RepositoriesService, githubOrganizationsService, gitlabOrganizationsService, configFile.CLALandingPage, configFile.CLALogoURL, emailService, eventsService, gitlabActivityService, gitlabApp)

sessionStore, err := dynastore.New(dynastore.Path("/"), dynastore.HTTPOnly(), dynastore.TableName(configFile.SessionStoreTableName), dynastore.DynamoDB(dynamodb.New(awsSession)))
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions cla-backend-go/swagger/cla.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4279,6 +4279,8 @@ paths:
description: Receives XML data when an individual signs a document in DocuSign linked to GitLab.
operationId: iclaCallbackGitlab
security: [ ]
consumes:
- text/xml
parameters:
- $ref: "#/parameters/x-request-id"
- name: user_id
Expand All @@ -4297,12 +4299,12 @@ paths:
in: path
required: true
type: string
- name: body
- name: envelopeInformation
in: body
required: true
description: XML payload with DocuSign envelope information
schema:
type: object
additionalProperties: true
$ref: '#/definitions/DocuSignEnvelopeInformation'
responses:
'200':
description: Callback data for GitLab successfully received and processed.
Expand Down
8 changes: 2 additions & 6 deletions cla-backend-go/v2/sign/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,8 @@ func Configure(api *operations.EasyclaAPI, service Service, userService users.Se
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
}
log.WithFields(f).Debug("gitlab callback")
payload, marshalErr := json.Marshal(params.Body)
if marshalErr != nil {
log.WithFields(f).WithError(marshalErr).Warn("unable to marshal github callback body")
return sign.NewIclaCallbackGithubBadRequest()
}

err := service.SignedIndividualCallbackGitlab(ctx, payload, params.UserID, params.OrganizationID, params.GitlabRepositoryID, params.MergeRequestID)
err := service.SignedIndividualCallbackGitlab(ctx, iclaGitHubPayload, params.UserID, params.OrganizationID, params.GitlabRepositoryID, params.MergeRequestID)
if err != nil {
return sign.NewIclaCallbackGitlabBadRequest()
}
Expand Down Expand Up @@ -256,6 +251,7 @@ func Configure(api *operations.EasyclaAPI, service Service, userService users.Se

api.AddMiddlewareFor("POST", "/signed/individual/{installation_id}/{github_repository_id}/{change_request_id}", docusignMiddleware)
api.AddMiddlewareFor("POST", "/signed/corporate/{project_id}/{company_id}", cclaDocusignMiddleware)
api.AddMiddlewareFor("POST", "/signed/gitlab/individual/{user_id}/{organization_id}/{gitlab_repository_id}/{merge_request_id}", docusignMiddleware)
}

type codedResponse interface {
Expand Down
Loading

0 comments on commit b187465

Please sign in to comment.