curl --request POST \
--url https://iam.basaltic.sh/v1/assume-role-with-web-identity \
--header 'Content-Type: application/json' \
--data '
{
"web_identity_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"role": "crn:iam::production:role/github-deployer",
"session_name": "reports-exporter",
"duration_seconds": 3600
}
'import requests
url = "https://iam.basaltic.sh/v1/assume-role-with-web-identity"
payload = {
"web_identity_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"role": "crn:iam::production:role/github-deployer",
"session_name": "reports-exporter",
"duration_seconds": 3600
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
web_identity_token: 'eyJhbGciOiJSUzI1NiIsImtpZCI6...',
role: 'crn:iam::production:role/github-deployer',
session_name: 'reports-exporter',
duration_seconds: 3600
})
};
fetch('https://iam.basaltic.sh/v1/assume-role-with-web-identity', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://iam.basaltic.sh/v1/assume-role-with-web-identity",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'web_identity_token' => 'eyJhbGciOiJSUzI1NiIsImtpZCI6...',
'role' => 'crn:iam::production:role/github-deployer',
'session_name' => 'reports-exporter',
'duration_seconds' => 3600
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://iam.basaltic.sh/v1/assume-role-with-web-identity"
payload := strings.NewReader("{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://iam.basaltic.sh/v1/assume-role-with-web-identity")
.header("Content-Type", "application/json")
.body("{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://iam.basaltic.sh/v1/assume-role-with-web-identity")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6ImF0K2p3dCIsImtpZCI6Ii4uLiJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"access_key_id": "AKIA...",
"secret_access_key": "wJalrXUtnFEMI...",
"session_token": "FwoGZXIvYXdzE...",
"expiration": "2026-01-15T09:30:00Z",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"account_handle": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "INVALID_INPUT",
"message": "Invalid request parameters",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "invalid web identity token",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "IAM_CANNOT_ASSUME_ROLE",
"message": "You are not authorized to assume this role",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests, please try again later",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "An internal error occurred",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NOT_IMPLEMENTED",
"message": "web identity federation is not configured",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "The service is temporarily unavailable. Please try again later.",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Assumir função com identidade web
Troque um token OIDC assinado por credenciais temporárias de uma role. Nenhuma credencial Basaltic existente é necessária. O CRN completo da role determina a conta; não há um seletor de conta separado.
Registre o emissor do token em /v1/oidc-providers na mesma conta da role. Assinatura, emissor, audiência permitida e validade são verificados antes da leitura da role. A política de confiança deve nomear o CRN do provedor e satisfazer todas as condições. Use basalt:webidentity:Subject para sub e basalt:webidentity:Audience para aud. A confiança no GitHub deve incluir uma restrição positiva do sujeito à organização ou ao repositório pretendido.
Registrar um provedor não concede acesso. Tokens inválidos retornam 401; um token verificado recusado pela confiança da role retorna 403. As requisições são limitadas por IP do cliente. Não é aceita uma política de sessão inline.
curl --request POST \
--url https://iam.basaltic.sh/v1/assume-role-with-web-identity \
--header 'Content-Type: application/json' \
--data '
{
"web_identity_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"role": "crn:iam::production:role/github-deployer",
"session_name": "reports-exporter",
"duration_seconds": 3600
}
'import requests
url = "https://iam.basaltic.sh/v1/assume-role-with-web-identity"
payload = {
"web_identity_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"role": "crn:iam::production:role/github-deployer",
"session_name": "reports-exporter",
"duration_seconds": 3600
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
web_identity_token: 'eyJhbGciOiJSUzI1NiIsImtpZCI6...',
role: 'crn:iam::production:role/github-deployer',
session_name: 'reports-exporter',
duration_seconds: 3600
})
};
fetch('https://iam.basaltic.sh/v1/assume-role-with-web-identity', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://iam.basaltic.sh/v1/assume-role-with-web-identity",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'web_identity_token' => 'eyJhbGciOiJSUzI1NiIsImtpZCI6...',
'role' => 'crn:iam::production:role/github-deployer',
'session_name' => 'reports-exporter',
'duration_seconds' => 3600
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://iam.basaltic.sh/v1/assume-role-with-web-identity"
payload := strings.NewReader("{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://iam.basaltic.sh/v1/assume-role-with-web-identity")
.header("Content-Type", "application/json")
.body("{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://iam.basaltic.sh/v1/assume-role-with-web-identity")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"web_identity_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6...\",\n \"role\": \"crn:iam::production:role/github-deployer\",\n \"session_name\": \"reports-exporter\",\n \"duration_seconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6ImF0K2p3dCIsImtpZCI6Ii4uLiJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"access_key_id": "AKIA...",
"secret_access_key": "wJalrXUtnFEMI...",
"session_token": "FwoGZXIvYXdzE...",
"expiration": "2026-01-15T09:30:00Z",
"account_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"account_handle": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "INVALID_INPUT",
"message": "Invalid request parameters",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "invalid web identity token",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "IAM_CANNOT_ASSUME_ROLE",
"message": "You are not authorized to assume this role",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests, please try again later",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "An internal error occurred",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "NOT_IMPLEMENTED",
"message": "web identity federation is not configured",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "The service is temporarily unavailable. Please try again later.",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Corpo
Troque um token OIDC assinado por credenciais na conta identificada pelo CRN completo da role.
Resposta
Função assumida com sucesso
As credenciais de uma sessão de função, em ambas as formas que podem ser apresentadas.
access_token é um token de portador para esta API — envie-o como Authorization: Bearer <token>. Os outros quatro campos são credenciais do AWS SigV4 para o endpoint de armazenamento de objetos compatível com o S3, que não diz mais nada.
Ambos vêm da mesma sessão e compartilham sua expiração, portanto, revogar a sessão interrompe ambos de uma só vez. Use o que o endpoint que você está chamando precisa; não há necessidade de escolher um no momento da solicitação.

