debian-mirror-gitlab/doc/api/secure_files.md

189 lines
6.2 KiB
Markdown
Raw Normal View History

2022-05-07 20:08:51 +05:30
---
stage: Verify
group: Pipeline Authoring
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2022-05-07 20:08:51 +05:30
type: reference, api
---
# Project-level Secure Files API **(FREE)**
2023-03-17 16:20:25 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78227) in GitLab 14.8. [Deployed behind the `ci_secure_files` flag](../administration/feature_flags.md), disabled by default.
> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/350748) in GitLab 15.7.
2022-05-07 20:08:51 +05:30
2023-03-17 16:20:25 +05:30
Limited to 100 secure files per project. Files must be smaller than 5 MB. Project-level Secure Files is an experimental feature developed by [GitLab Incubation Engineering](https://about.gitlab.com/handbook/engineering/incubation/).
2022-05-07 20:08:51 +05:30
## List project secure files
Get list of secure files in a project.
```plaintext
GET /projects/:project_id/secure_files
```
Supported attributes:
| Attribute | Type | Required | Description |
|--------------|----------------|------------------------|-------------|
2023-04-23 21:23:45 +05:30
| `project_id` | integer/string | **{check-circle}** Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
2022-05-07 20:08:51 +05:30
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files"
```
Example response:
```json
[
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
2023-01-13 00:05:48 +05:30
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
2022-05-07 20:08:51 +05:30
},
{
"id": 2,
2023-01-13 00:05:48 +05:30
"name": "myfile.cer",
2022-05-07 20:08:51 +05:30
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aa2",
"checksum_algorithm": "sha256",
2023-01-13 00:05:48 +05:30
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": "2022-09-21T14:56:00.000Z",
"metadata": {
"id":"75949910542696343243264405377658443914",
"issuer": {
"C":"US",
"O":"Apple Inc.",
"CN":"Apple Worldwide Developer Relations Certification Authority",
"OU":"G3"
},
"subject": {
"C":"US",
"O":"Organization Name",
"CN":"Apple Distribution: Organization Name (ABC123XYZ)",
"OU":"ABC123XYZ",
"UID":"ABC123XYZ"
},
"expires_at":"2022-09-21T14:56:00.000Z"
}
2022-05-07 20:08:51 +05:30
}
]
```
## Show secure file details
Get the details of a specific secure file in a project.
```plaintext
GET /projects/:project_id/secure_files/:id
```
Supported attributes:
| Attribute | Type | Required | Description |
|--------------|----------------|------------------------|-------------|
2023-04-23 21:23:45 +05:30
| `project_id` | integer/string | **{check-circle}** Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
2022-05-07 20:08:51 +05:30
| `id` | integer | **{check-circle}** Yes | The `id` of a secure file. |
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files/1"
```
Example response:
```json
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
2023-01-13 00:05:48 +05:30
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
2022-05-07 20:08:51 +05:30
}
```
## Create secure file
Create a new secure file.
```plaintext
POST /projects/:project_id/secure_files
```
Supported attributes:
2022-06-21 17:19:12 +05:30
| Attribute | Type | Required | Description |
|-----------------|----------------|------------------------|-------------|
2023-04-23 21:23:45 +05:30
| `project_id` | integer/string | **{check-circle}** Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
2022-07-23 23:45:48 +05:30
| `name` | string | **{check-circle}** Yes | The `name` of the file being uploaded. The filename must be unique within the project. |
2022-06-21 17:19:12 +05:30
| `file` | file | **{check-circle}** Yes | The `file` being uploaded (5 MB limit). |
2022-05-07 20:08:51 +05:30
Example request:
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/projects/1/secure_files" --form "name=myfile.jks" --form "file=@/path/to/file/myfile.jks"
```
Example response:
```json
{
"id": 1,
"name": "myfile.jks",
"checksum": "16630b189ab34b2e3504f4758e1054d2e478deda510b2b08cc0ef38d12e80aac",
"checksum_algorithm": "sha256",
2023-01-13 00:05:48 +05:30
"created_at": "2022-02-22T22:22:22.222Z",
"expires_at": null,
"metadata": null
2022-05-07 20:08:51 +05:30
}
```
## Download secure file
Download the contents of a project's secure file.
```plaintext
2022-11-25 23:54:43 +05:30
GET /projects/:project_id/secure_files/:id/download
2022-05-07 20:08:51 +05:30
```
Supported attributes:
| Attribute | Type | Required | Description |
|--------------|----------------|------------------------|-------------|
2023-04-23 21:23:45 +05:30
| `project_id` | integer/string | **{check-circle}** Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
2022-05-07 20:08:51 +05:30
| `id` | integer | **{check-circle}** Yes | The `id` of a secure file. |
Example request:
```shell
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/secure_files/1/download --output myfile.jks
```
## Remove secure file
Remove a project's secure file.
```plaintext
DELETE /projects/:project_id/secure_files/:id
```
Supported attributes:
| Attribute | Type | Required | Description |
|--------------|----------------|------------------------|-------------|
2023-04-23 21:23:45 +05:30
| `project_id` | integer/string | **{check-circle}** Yes | The ID or [URL-encoded path of the project](rest/index.md#namespaced-path-encoding) owned by the authenticated user. |
2022-05-07 20:08:51 +05:30
| `id` | integer | **{check-circle}** Yes | The `id` of a secure file. |
Example request:
```shell
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/secure_files/1"
```