1+ ---
2+ # Application name for this connector configuration
3+ app_name : MySQL Local Test
4+ app_description : Test configuration for MySQL with employee_id and last_login support (for local testing)
5+
6+ # Connection settings for the MySQL database
7+ connect :
8+ # Data Source Name (DSN) for our local MySQL instance running in Docker
9+ dsn : " mysql://baton:password@localhost:3306/batondb"
10+
11+ # Definition of different resource types managed by this connector
12+ resource_types :
13+ # Configuration for "user" resources in MySQL
14+ user :
15+ # Display name for this resource type
16+ name : " User"
17+ # Description providing context about what a user represents
18+ description : " A user within the MySQL system"
19+ # Settings for listing user records from the database
20+ list :
21+ # SQL query to fetch user-related data including employee_id, last_login, and manager information
22+ query : |
23+ SELECT
24+ u.id,
25+ u.username,
26+ u.email,
27+ u.employee_id,
28+ u.status,
29+ u.account_type,
30+ u.created_at,
31+ u.last_login,
32+ u.manager_id,
33+ m.username as manager_username,
34+ m.email as manager_email
35+ FROM
36+ users u
37+ LEFT JOIN
38+ users m ON u.manager_id = m.id
39+ # Pagination configuration (using offset for MySQL)
40+ pagination :
41+ strategy : " offset"
42+ primary_key : " id"
43+ # Mapping of query results to resource fields
44+ map :
45+ # Unique identifier for the user resource
46+ id : " .username"
47+ # Field to display as the resource's name
48+ display_name : " .username"
49+ # Additional description for the user resource
50+ description : " .username"
51+ # Extra attributes (traits) for the user resource
52+ traits :
53+ user :
54+ # Map status from database (active, disabled) to proper resource status
55+ status : " .status"
56+ # Login identifier - username
57+ login : " .username"
58+ # Email addresses
59+ emails :
60+ - " .email"
61+ # Account type mapping
62+ account_type : " .account_type"
63+ # Employee ID mapping
64+ employee_ids :
65+ - " .employee_id"
66+ # Last login timestamp mapping
67+ last_login : " .last_login"
68+ # Manager information
69+ manager_id : " .manager_id"
70+ manager_email : " .manager_email"
71+
72+ # Profile details for the user
73+ profile :
74+ user_id : " .id"
75+ created_at : " .created_at"
76+ last_login : " .last_login"
77+ manager_id : " .manager_id"
78+ manager_username : " .manager_username"
79+ manager_email : " .manager_email"
80+
81+ # Configuration for "role" resources
82+ role :
83+ # Display name for the role resource type
84+ name : " Role"
85+ # Brief description of what a role signifies
86+ description : " A role within the MySQL system"
87+ # Settings for listing roles from the database
88+ list :
89+ # SQL query to retrieve roles
90+ query : |
91+ SELECT
92+ id,
93+ role_name
94+ FROM
95+ roles
96+ # Pagination configuration
97+ pagination :
98+ strategy : " offset"
99+ primary_key : " id"
100+ # Mapping of each query result to role resource fields
101+ map :
102+ # Unique role identifier
103+ id : " .role_name"
104+ # Display name for the role
105+ display_name : " .role_name"
106+ # Role description
107+ description : " .role_name"
108+ # Additional role-specific traits
109+ traits :
110+ role :
111+ # Profile mapping for the role
112+ profile :
113+ role_id : " .id"
114+
115+ # Define a static entitlement for role membership
116+ static_entitlements :
117+ - id : " member"
118+ display_name : " 'Member'"
119+ description : " 'Role member'"
120+ purpose : " assignment"
121+ grantable_to :
122+ - " user"
123+
124+ # Dynamic grants based on SQL queries to associate users with roles
125+ grants :
126+ - query : |
127+ SELECT
128+ u.username,
129+ r.role_name
130+ FROM
131+ users u
132+ JOIN
133+ user_roles ur ON u.id = ur.user_id
134+ JOIN
135+ roles r ON r.id = ur.role_id
136+ pagination:
137+ strategy: "offset"
138+ primary_key: "username"
139+ map:
140+ - skip_if: ".role_name != resource.ID"
141+ principal_id: ".username"
142+ principal_type: "user"
143+ entitlement_id: "member"
0 commit comments