cURL
curl --request POST \
--url https://api.osohq.com/api/evaluate_query_local \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"predicate": [
"<unknown>"
],
"calls": [
[
"<unknown>"
]
],
"constraints": {},
"context_facts": [
{
"predicate": "<string>",
"args": [
{
"type": "<string>",
"id": "<string>"
}
]
}
]
},
"data_bindings": "<string>",
"mode": {
"mode": "select",
"query_vars_to_output_column_names": {}
}
}
'from oso_cloud import Oso, Value
import os
from sqlalchemy import text
from oso_cloud import Oso, Value
oso = Oso(api_key=os.environ.get('OSO_CLOUD_API_KEY', None))
# Generate SQL for field-level authorization
actor = Value("User", "alice")
resource = Value("Issue", "123")
field = "description"
sql_query = oso.build_query((
"allow_field",
actor,
"read",
resource,
field
)).evaluate_local_select({"field_name": field})
# Execute field authorization query
field_result = session.execute(text(sql_query)).fetchall()import { Oso } from 'oso-cloud';
const apiKey = process.env.OSO_CLOUD_API_KEY;
const oso = new Oso("https://cloud.osohq.com", apiKey);
// Generate SQL for field-level authorization
const actor = { type: "User", id: "alice" };
const resource = { type: "Issue", id: "123" };
const field = "description";
const sqlQuery = await oso.buildQuery([
"allow_field",
actor,
"read",
resource,
field
]).evaluateLocalSelect({ field_name: field });
// Execute field authorization query
const fieldResult = await sql.raw(sqlQuery).execute(db);package main
import (
"log"
"os"
oso "github.com/osohq/go-oso-cloud/v2"
)
func main() {
apiKey := os.Getenv("OSO_CLOUD_API_KEY")
osoClient := oso.NewClient("https://cloud.osohq.com", apiKey)
// Generate SQL for field-level authorization
actor := oso.NewValue("User", "alice")
resource := oso.NewValue("Issue", "123")
fieldVar := oso.NewVariable("field")
sqlQuery, err := osoClient.BuildQuery(
oso.NewQueryFact("allow_field", actor, oso.String("read"), resource, fieldVar),
).EvaluateLocalSelect(map[string]oso.Variable{"field_name": fieldVar})
if err != nil {
log.Fatal(err)
}
// Execute field authorization query
var fieldResult []map[string]interface{}
db.Raw(sqlQuery).Scan(&fieldResult)
}package com.mycompany;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.osohq.oso_cloud.Oso;
import com.osohq.oso_cloud.api.ApiException;
import com.osohq.oso_cloud.api.Value;
public class App {
public static void main(String[] args) {
String apiKey = System.getenv("OSO_CLOUD_API_KEY");
Oso oso = new Oso(apiKey);
try {
// Generate SQL for field-level authorization
Value actor = new Value("User", "alice");
Value resource = new Value("Issue", "123");
String field = "description";
String sqlQuery = oso.buildQuery("allow_field", actor, "read", resource, field)
.evaluateLocalSelect(Map.of("field_name", field));
// Execute field authorization query
List<Map<String, Object>> fieldResult = entityManager.createNativeQuery(sqlQuery)
.getResultList();
} catch (IOException | ApiException e) {
System.err.println("Error: " + e.getMessage());
}
}
}require 'oso-cloud'
api_key = ENV.fetch('OSO_CLOUD_API_KEY', nil)
oso = OsoCloud::Oso.new(url: "https://cloud.osohq.com", api_key: api_key)
# Generate SQL for field-level authorization
actor = OsoCloud::Value.new(type: "User", id: "alice")
resource = OsoCloud::Value.new(type: "Issue", id: "123")
field = "description"
sql_query = oso.build_query(["allow_field", actor, "read", resource, field])
.evaluate_local_select({"field_name" => field})
# Execute field authorization query
field_result = ActiveRecord::Base.connection.execute(sql_query)using OsoCloud;
using System.Collections.Generic;
string? apiKey = Environment.GetEnvironmentVariable("OSO_CLOUD_API_KEY");
var oso = new Oso("https://api.osohq.com", apiKey);
// Generate SQL for field-level authorization
var actor = new Value("User", "alice");
var resource = new Value("Issue", "123");
string field = "description";
string sqlQuery = await oso.BuildQuery("allow_field", actor, "read", resource, field)
.EvaluateLocalSelect(new Dictionary<string, string> { { "field_name", field } });
// Execute field authorization query
var fieldResult = await context.Database.SqlQueryRaw<object>(sqlQuery).ToListAsync();{
"sql": "<string>"
}{
"message": "<string>"
}Local Check API
Post evaluate query local
Fetches a SQL query that can be run against your database to answer arbitrary questions about authorization.
POST
/
evaluate_query_local
cURL
curl --request POST \
--url https://api.osohq.com/api/evaluate_query_local \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"predicate": [
"<unknown>"
],
"calls": [
[
"<unknown>"
]
],
"constraints": {},
"context_facts": [
{
"predicate": "<string>",
"args": [
{
"type": "<string>",
"id": "<string>"
}
]
}
]
},
"data_bindings": "<string>",
"mode": {
"mode": "select",
"query_vars_to_output_column_names": {}
}
}
'from oso_cloud import Oso, Value
import os
from sqlalchemy import text
from oso_cloud import Oso, Value
oso = Oso(api_key=os.environ.get('OSO_CLOUD_API_KEY', None))
# Generate SQL for field-level authorization
actor = Value("User", "alice")
resource = Value("Issue", "123")
field = "description"
sql_query = oso.build_query((
"allow_field",
actor,
"read",
resource,
field
)).evaluate_local_select({"field_name": field})
# Execute field authorization query
field_result = session.execute(text(sql_query)).fetchall()import { Oso } from 'oso-cloud';
const apiKey = process.env.OSO_CLOUD_API_KEY;
const oso = new Oso("https://cloud.osohq.com", apiKey);
// Generate SQL for field-level authorization
const actor = { type: "User", id: "alice" };
const resource = { type: "Issue", id: "123" };
const field = "description";
const sqlQuery = await oso.buildQuery([
"allow_field",
actor,
"read",
resource,
field
]).evaluateLocalSelect({ field_name: field });
// Execute field authorization query
const fieldResult = await sql.raw(sqlQuery).execute(db);package main
import (
"log"
"os"
oso "github.com/osohq/go-oso-cloud/v2"
)
func main() {
apiKey := os.Getenv("OSO_CLOUD_API_KEY")
osoClient := oso.NewClient("https://cloud.osohq.com", apiKey)
// Generate SQL for field-level authorization
actor := oso.NewValue("User", "alice")
resource := oso.NewValue("Issue", "123")
fieldVar := oso.NewVariable("field")
sqlQuery, err := osoClient.BuildQuery(
oso.NewQueryFact("allow_field", actor, oso.String("read"), resource, fieldVar),
).EvaluateLocalSelect(map[string]oso.Variable{"field_name": fieldVar})
if err != nil {
log.Fatal(err)
}
// Execute field authorization query
var fieldResult []map[string]interface{}
db.Raw(sqlQuery).Scan(&fieldResult)
}package com.mycompany;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.osohq.oso_cloud.Oso;
import com.osohq.oso_cloud.api.ApiException;
import com.osohq.oso_cloud.api.Value;
public class App {
public static void main(String[] args) {
String apiKey = System.getenv("OSO_CLOUD_API_KEY");
Oso oso = new Oso(apiKey);
try {
// Generate SQL for field-level authorization
Value actor = new Value("User", "alice");
Value resource = new Value("Issue", "123");
String field = "description";
String sqlQuery = oso.buildQuery("allow_field", actor, "read", resource, field)
.evaluateLocalSelect(Map.of("field_name", field));
// Execute field authorization query
List<Map<String, Object>> fieldResult = entityManager.createNativeQuery(sqlQuery)
.getResultList();
} catch (IOException | ApiException e) {
System.err.println("Error: " + e.getMessage());
}
}
}require 'oso-cloud'
api_key = ENV.fetch('OSO_CLOUD_API_KEY', nil)
oso = OsoCloud::Oso.new(url: "https://cloud.osohq.com", api_key: api_key)
# Generate SQL for field-level authorization
actor = OsoCloud::Value.new(type: "User", id: "alice")
resource = OsoCloud::Value.new(type: "Issue", id: "123")
field = "description"
sql_query = oso.build_query(["allow_field", actor, "read", resource, field])
.evaluate_local_select({"field_name" => field})
# Execute field authorization query
field_result = ActiveRecord::Base.connection.execute(sql_query)using OsoCloud;
using System.Collections.Generic;
string? apiKey = Environment.GetEnvironmentVariable("OSO_CLOUD_API_KEY");
var oso = new Oso("https://api.osohq.com", apiKey);
// Generate SQL for field-level authorization
var actor = new Value("User", "alice");
var resource = new Value("Issue", "123");
string field = "description";
string sqlQuery = await oso.BuildQuery("allow_field", actor, "read", resource, field)
.EvaluateLocalSelect(new Dictionary<string, string> { { "field_name", field } });
// Execute field authorization query
var fieldResult = await context.Database.SqlQueryRaw<object>(sqlQuery).ToListAsync();{
"sql": "<string>"
}{
"message": "<string>"
}Authorizations
Requires an API key to access.
Body
application/json
Response
Was this page helpful?
⌘I