Skip to content

Commit

Permalink
fix: add X-CSRF-Token header to handle other versions of gitlab
Browse files Browse the repository at this point in the history
it's good that I'm able to test on other environments too
(this was needed on self-hosted GitLab Community edition)
  • Loading branch information
Kipras Melnikovas authored and kiprasmel committed Sep 30, 2020
1 parent 85078b3 commit 53bdc4e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/gitbeaker-requester-utils/src/BaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,20 @@ export class BaseService {
gitlabCSRFTokenValue,
} = nativeAuth;

/**
*
* step 1 - handle CSRF
*
* some gitlab instances need the CSRF token to be added via the body,
* and some need the `X-CSRF-Token` header. We handle both.
*/
this.additionalBody = { ...this.additionalBody, [gitlabCSRFTokenKey]: gitlabCSRFTokenValue };

this.headers['X-CSRF-Token'] = gitlabCSRFTokenValue;

/**
* step 2 - handle the session cookie
*/
if (!this.headers.cookie) {
this.headers.cookie = 'cookie: ';
}
Expand Down

0 comments on commit 53bdc4e

Please sign in to comment.