EQTY LabDocs

Validate a credential and resolve the caller

Validate an IDP JWT, an enriched JWT issued by this service, or an API key supplied via Authorization: Bearer <jwt_or_api_key>, sync user data when applicable, and return the resolved user, organization, and permissions

posthttps://localhost:8080/api/v1/auth/validate
bash
curl --request POST \
  --url 'https://localhost:8080/api/v1/auth/validate' \
  --header 'Authorization: Bearer <token>'
javascript
const response = await fetch("https://localhost:8080/api/v1/auth/validate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <token>"
  }
});

const data = await response.json();
typescript
interface ValidateTokenResponse {
  authType?: string;
  claims?: Record<string, unknown>;
  email?: string;
  keyHeldScopes?: string[];
  keyId?: string;
  keyProjectId?: number;
  keyScopes?: string[];
  keyUnrestricted?: boolean;
  name?: string;
  organization?: Record<string, unknown>;
  permissions?: string[];
  userId?: string;
  valid?: boolean;
}

const response = await fetch("https://localhost:8080/api/v1/auth/validate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <token>"
  }
});
if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);

const data: ValidateTokenResponse = await response.json();
python
import requests

response = requests.post(
    "https://localhost:8080/api/v1/auth/validate",
    headers={
        "Authorization": "Bearer <token>",
    },
)
response.raise_for_status()
print(response.json())
go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest(http.MethodPost, "https://localhost:8080/api/v1/auth/validate", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	data, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Status, string(data))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://localhost:8080/api/v1/auth/validate"))
            .header("Authorization", "Bearer <token>")
            .method("POST", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
csharp
using System.Net.Http.Headers;

using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://localhost:8080/api/v1/auth/validate");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "<token>");

using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
php
<?php

$ch = curl_init('https://localhost:8080/api/v1/auth/validate');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
    ],
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
echo $status . " " . $response . PHP_EOL;
ruby
require "net/http"

uri = URI("https://localhost:8080/api/v1/auth/validate")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer <token>"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
puts "#{response.code} #{response.body}"
rust
// Cargo.toml dependencies: reqwest, tokio (features "full")

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let response = reqwest::Client::new()
        .post("https://localhost:8080/api/v1/auth/validate")
        .header("Authorization", "Bearer <token>")
        .send()
        .await?;

    println!("{} {}", response.status(), response.text().await?);
    Ok(())
}

Parameters

Header parameters

NameTypeDescription
Authorization
required
string

Bearer {jwt_or_api_key}

Responses

200Token is valid

application/json
  • authTypestring

    API-key principals only

  • claimsobject
    Show properties

    Map of any

  • emailstring
  • keyHeldScopesstring[]

    KeyHeldScopes are the permissions among an attenuated key's scopes that its holder still holds in the key's organization, read from their memberships on every validation. A service that lets a key act for its holder on a scope reads these: keyScopes are only what the key was created with

  • keyIdstring

    API-key principals only

  • keyProjectIdinteger

    The project an API key is bound to; absent for an organization-wide key

  • keyScopesstring[]

    API-key principals only

  • keyUnrestrictedboolean

    True for an API key neither scope-attenuated nor project-bound: it carries its owner's whole standing

  • namestring
  • organizationhandlers.OrganizationInfo

    The organization a validated token is scoped to, and the roles it carries there

    Show handlers.OrganizationInfo
    • idinteger
    • namestring
    • rolesstring[]
    • uuidstring<uuid>

      Absent when the organization row could not be read; never the zero UUID

  • permissionsstring[]
  • userIdstring
  • validboolean
Examplejson
{
  "authType": "string",
  "claims": {
    "key": null
  },
  "email": "string",
  "keyHeldScopes": [
    "string"
  ],
  "keyId": "string",
  "keyProjectId": 0,
  "keyScopes": [
    "string"
  ],
  "keyUnrestricted": true,
  "name": "string",
  "organization": {
    "id": 0,
    "name": "string",
    "roles": [
      "string"
    ],
    "uuid": "00000000-0000-0000-0000-000000000000"
  },
  "permissions": [
    "string"
  ],
  "userId": "string",
  "valid": true
}

401Token is invalid or expired

application/json
  • errorstring
  • error_descriptionstring
Examplejson
{
  "error": "Unauthorized",
  "error_description": "Invalid token"
}

500Internal server error

application/json
  • errorstring
  • error_descriptionstring
Examplejson
{
  "error": "Unauthorized",
  "error_description": "Invalid token"
}