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"
}
}Asumir rol con identidad web
Intercambie un token OIDC firmado por credenciales temporales de un rol. No se requieren credenciales Basaltic previas. El CRN completo del rol determina la cuenta; no hay un selector de cuenta separado.
Registre el emisor del token en /v1/oidc-providers en la misma cuenta del rol. Se verifican la firma, el emisor, la audiencia permitida y la vigencia antes de leer el rol. La política de confianza debe indicar el CRN del proveedor y cumplir todas las condiciones. Use basalt:webidentity:Subject para sub y basalt:webidentity:Audience para aud. La confianza en GitHub debe incluir una restricción positiva del sujeto a la organización o al repositorio previsto.
Registrar un proveedor no concede acceso. Los tokens inválidos devuelven 401; un token verificado rechazado por la confianza del rol devuelve 403. Las solicitudes se limitan por IP del cliente. No se acepta una política de sesión 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"
}
}Cuerpo
Intercambie un token OIDC firmado por credenciales en la cuenta identificada por el CRN completo del rol.
Respuesta
Función asumida con éxito
Las credenciales de una sesión de rol, en ambas formas que se pueden presentar.
access_token es un token portador para esta API — envíelo como Authorization: Bearer <token>. Los otros cuatro campos son credenciales de AWS SigV4 para el punto final de almacenamiento de objetos compatible con S3, que no dice nada más.
Ambos provienen de la misma sesión y comparten su vencimiento, por lo que revocar la sesión detiene a ambos a la vez. Utilice cualquiera que sea el punto final que está llamando; no hay necesidad de elegir uno en el momento de la solicitud.

