Skip to content

Commit 8b5b0da

Browse files
authored
Merge pull request #35 from ConductorOne/jirwin/no-transactions-provisioning
Jirwin/no transactions provisioning
2 parents 086b4dc + bb75fb2 commit 8b5b0da

File tree

7 files changed

+773
-126
lines changed

7 files changed

+773
-126
lines changed

README.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
![Baton Logo](./docs/images/baton-logo.png)
2-
31
# `baton-sql` [![Go Reference](https://pkg.go.dev/badge/github.com/conductorone/baton-sql.svg)](https://pkg.go.dev/github.com/conductorone/baton-sql) ![main ci](https://github.com/conductorone/baton-sql/actions/workflows/main.yaml/badge.svg)
42

53
`baton-sql` is a connector for built using the [Baton SDK](https://github.com/conductorone/baton-sdk).
64

7-
Check out [Baton](https://github.com/conductorone/baton) to learn more the project in general.
5+
## Overview
86

9-
# Contributing, Support and Issues
7+
`baton-sql` is a connector that enables you to sync identities, resources, and permissions from SQL databases. It provides a flexible configuration system that allows you to map the results of database queries to resources and entitlements.
108

11-
We started Baton because we were tired of taking screenshots and manually
12-
building spreadsheets. We welcome contributions, and ideas, no matter how
13-
small—our goal is to make identity and permissions sprawl less painful for
14-
everyone. If you have questions, problems, or ideas: Please open a GitHub Issue!
9+
## Supported Database Engines
1510

16-
See [CONTRIBUTING.md](https://github.com/ConductorOne/baton/blob/main/CONTRIBUTING.md) for more details.
11+
- MySQL
12+
- Microsoft SQL Server
13+
- Oracle
14+
- PostgreSQL (soon)
15+
- SQLite (soon)
1716

18-
# `baton-sql` Command Line Usage
17+
## Configuration
1918

20-
```
21-
baton-sql
19+
The connector is configured using a YAML file that defines:
2220

21+
- Database connection details via DSN or individual connection parameters
22+
- Resource types (e.g. users, groups, roles) mapped to database tables/queries
23+
- Entitlements that can be granted to resources
24+
- Provisioning actions for granting/revoking entitlements
25+
26+
See examples in the [examples](https://github.com/ConductorOne/baton-sql/tree/main/examples) directory.
27+
28+
## `baton-sql` Command Line Usage
29+
```
2330
Usage:
2431
baton-sql [flags]
2532
baton-sql [command]
@@ -44,3 +51,14 @@ Flags:
4451
4552
Use "baton-sql [command] --help" for more information about a command.
4653
```
54+
55+
# Contributing, Support and Issues
56+
57+
We started Baton because we were tired of taking screenshots and manually
58+
building spreadsheets. We welcome contributions, and ideas, no matter how
59+
small—our goal is to make identity and permissions sprawl less painful for
60+
everyone. If you have questions, problems, or ideas: Please open a GitHub Issue!
61+
62+
Check out [Baton](https://github.com/conductorone/baton) to learn more the project in general.
63+
64+
See [CONTRIBUTING.md](https://github.com/ConductorOne/baton/blob/main/CONTRIBUTING.md) for more details.

examples/example.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
# Connector Configuration Reference
3+
# ===============================
4+
# This is a reference configuration demonstrating all available options
5+
# and their purposes in a connector configuration file.
6+
7+
# The application name that identifies this connector
8+
app_name: Example Application
9+
10+
# Connection Configuration
11+
# ----------------------
12+
# Specifies how to connect to the data source. Supports various connection methods.
13+
connect:
14+
# Database connection string (DSN) with environment variable interpolation
15+
dsn: "mysql://${DB_USER}:${DB_PASS}@${DB_HOST}:3306/${DB_NAME}?parseTime=true"
16+
# If your database username or password includes characters that require URL encoding,
17+
# you can specify them as separate options instead of embedding them directly in the DSN.
18+
# Environment variables are expanded.
19+
# For example, you might include:
20+
# username: my_username
21+
# password: my_secure_password
22+
#
23+
# This allows the connector to handle proper URL encoding during DSN construction.
24+
25+
# Resource Types
26+
# -------------
27+
# Defines the resources that can be synchronized from the data source.
28+
# Each resource type represents a distinct entity type (e.g., users, groups, roles).
29+
resource_types:
30+
31+
# Example User Resource
32+
# -------------------
33+
user:
34+
name: "User" # Display name for this resource type
35+
description: "Represents a user account in the system"
36+
37+
# List Configuration
38+
# ----------------
39+
# Defines how to retrieve a list of resources
40+
list:
41+
# SQL query to fetch resources. Supports multiple query types:
42+
# - Direct SQL queries
43+
# - Stored procedure calls
44+
# - Complex joins and subqueries
45+
query: |
46+
SELECT
47+
id,
48+
username,
49+
email,
50+
created_at,
51+
status,
52+
department
53+
FROM users
54+
WHERE status = 'active'
55+
AND id > ?<Cursor>
56+
ORDER BY id ASC
57+
LIMIT ?<Limit>
58+
59+
# Mapping Configuration
60+
# -------------------
61+
# Defines how to transform raw data into standardized resource objects
62+
map:
63+
# Required Fields
64+
# --------------
65+
# These fields are required for all resources
66+
id: ".id" # Maps the 'id' column to the resource ID
67+
display_name: ".username" # Human-readable name
68+
description: "string(.department) + ' department user'" # Can use CEL expressions
69+
70+
# Optional Traits
71+
# --------------
72+
# Custom attributes specific to this resource type
73+
traits:
74+
user:
75+
# The trait name defines the schema
76+
emails:
77+
# Array fields
78+
- ".email" # Direct field mapping
79+
- "lowercase(.email)" # CEL transformation
80+
status: ".status" # Simple field mapping
81+
profile:
82+
department: ".department"
83+
joined_date: ".created_at"
84+
# Complex CEL transformation example
85+
full_name: "titleCase(.first_name) + ' ' + titleCase(.last_name)"
86+
87+
# Pagination Configuration
88+
# ----------------------
89+
# Defines how to handle large result sets
90+
pagination:
91+
strategy: "cursor" # Options: "cursor", "offset"
92+
primary_key: "id" # Column used for pagination tracking
93+
94+
# Static Entitlements
95+
# ------------------
96+
# Pre-defined permissions that can be granted
97+
static_entitlements:
98+
- id: "access" # Unique identifier for this entitlement
99+
display_name: "Basic Access"
100+
description: "Provides basic access to the application"
101+
purpose: "access" # Purpose: "access", "assignment", "permission"
102+
grantable_to:
103+
# Resource types that can receive this entitlement
104+
- "user"
105+
- "service_account"
106+
# Provisioning Configuration
107+
# ------------------------
108+
# Defines how to implement entitlement changes
109+
provisioning:
110+
vars:
111+
# Variables available in provisioning queries
112+
user_id: "principal.ID"
113+
access_level: "'basic'"
114+
115+
# Grant Operations
116+
# ---------------
117+
grant:
118+
# SQL statements to execute when granting
119+
queries:
120+
- |
121+
INSERT INTO user_access (user_id, level)
122+
VALUES (?<user_id>, ?<access_level>)
123+
124+
# Revoke Operations
125+
# ----------------
126+
revoke:
127+
# SQL statements to execute when revoking
128+
queries:
129+
- |
130+
DELETE FROM user_access
131+
WHERE user_id = ?<user_id>
132+
# Grants Query Configuration
133+
# ------------------------
134+
# Defines how to discover existing entitlements
135+
grants:
136+
- query: |
137+
SELECT
138+
user_id,
139+
access_level,
140+
granted_at
141+
FROM user_access
142+
LIMIT ?<Limit> OFFSET ?<Offset>
143+
144+
# Grant Mapping
145+
# ------------
146+
# Defines how to interpret grant query results
147+
map:
148+
- skip_if: ".access_level != 'basic'" # CEL condition to filter results
149+
principal_id: ".user_id"
150+
principal_type: "user"
151+
entitlement_id: "access"
152+
# Grants Pagination
153+
# ----------------
154+
pagination:
155+
strategy: "offset"
156+
primary_key: "user_id"
157+
158+
# Additional resource types would follow the same pattern
159+
# Example: groups, roles, applications, etc.

0 commit comments

Comments
 (0)