curl --request POST \
--url https://app.trustivan.com/api/v1/git-credentials/{id}/check-access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repository": "https://github.com/acme/api"
}
'import requests
url = "https://app.trustivan.com/api/v1/git-credentials/{id}/check-access"
payload = { "repository": "https://github.com/acme/api" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({repository: 'https://github.com/acme/api'})
};
fetch('https://app.trustivan.com/api/v1/git-credentials/{id}/check-access', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.trustivan.com/api/v1/git-credentials/{id}/check-access"
payload := strings.NewReader("{\n \"repository\": \"https://github.com/acme/api\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"credential": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"kind": "registry",
"registry": "ghcr.io",
"scheme": "basic",
"status": "unverified",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"username": "<string>",
"external_id": "<string>",
"status_reason": "<string>",
"last_verified_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"rotated_at": "2023-11-07T05:31:56Z",
"created_by": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"access": {
"ok": true,
"rejected": true,
"reason": "<string>",
"repository": "<string>"
}
}Check that a credential can read a repository
Answers “will my next scan of this repository work?” WITHOUT cloning
it. One smart-HTTP advertisement request (what git ls-remote sends,
and the request that authenticates), so nothing of the customer’s
source code is written to the API host.
A repository must be named. There is no host-level equivalent of the
registry’s GET /v2/: a fine-grained GitHub token or a GitLab deploy
token scoped to one repository grants nothing at the host level, so a
host-level check would report a working credential as broken.
The RESULT is in the body, never in the status code. A refused credential is a successful request: a client reading a 4xx could not tell “the token is wrong” from “TRUSTIVAN is down”.
Only a host that actively REJECTED the credential changes its stored status. An unreachable host leaves it alone.
Requires credentials:manage and a human principal, because it makes
an outbound authentication attempt on the customer’s account.
curl --request POST \
--url https://app.trustivan.com/api/v1/git-credentials/{id}/check-access \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repository": "https://github.com/acme/api"
}
'import requests
url = "https://app.trustivan.com/api/v1/git-credentials/{id}/check-access"
payload = { "repository": "https://github.com/acme/api" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({repository: 'https://github.com/acme/api'})
};
fetch('https://app.trustivan.com/api/v1/git-credentials/{id}/check-access', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.trustivan.com/api/v1/git-credentials/{id}/check-access"
payload := strings.NewReader("{\n \"repository\": \"https://github.com/acme/api\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"credential": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"kind": "registry",
"registry": "ghcr.io",
"scheme": "basic",
"status": "unverified",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"username": "<string>",
"external_id": "<string>",
"status_reason": "<string>",
"last_verified_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"rotated_at": "2023-11-07T05:31:56Z",
"created_by": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"access": {
"ok": true,
"rejected": true,
"reason": "<string>",
"repository": "<string>"
}
}Authorizations
Body
Response
The check completed. access.ok is the answer.