Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Add username field to secure repos #3116

Merged
merged 2 commits into from
Jun 15, 2020
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
8 changes: 8 additions & 0 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,14 @@ components:
type: boolean
protected:
type: boolean
authentication:
type: object
properties:
username:
description: user's github username
type: string
example: 'user'

TemplateRepoSetting:
type: object
required:
Expand Down
3 changes: 3 additions & 0 deletions src/pfe/portal/modules/Templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ async function constructRepositoryObject(url, description, name, isRepoProtected
if (isRepoProtected !== undefined) {
repository.protected = isRepoProtected;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi protected means "this repository should not be deleted". (It doesn't mean "this repository is secure / requires authentication")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks! Do we have an alternative? Or do we only need git user/password on authenticated repos?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea we only need to add the authenticated field to the template repo object if the repo is authenticated / requires auth.

So your 'trigger' for adding the field can be just if there are gitCredentials. (Maybe check that if the gitCredentials are invalid we will error before reaching this point)

}
if (gitCredentials && gitCredentials.username) {
repository.authentication = { username: gitCredentials.username };
}
return repository;
}

Expand Down