Skip to content

Commit def1768

Browse files
add user provisioning
1 parent 70c3ceb commit def1768

File tree

5 files changed

+537
-37
lines changed

5 files changed

+537
-37
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,14 @@ jobs:
4343

4444
test:
4545
runs-on: ubuntu-latest
46-
# Define any services needed for the test suite (or delete this section)
47-
# services:
48-
# postgres:
49-
# image: postgres:16
50-
# ports:
51-
# - "5432:5432"
52-
# env:
53-
# POSTGRES_PASSWORD: secretpassword
46+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
5447
env:
5548
BATON_LOG_LEVEL: debug
56-
# Add any environment variables needed to run baton-snowflake
57-
# BATON_BASE_URL: 'http://localhost:8080'
58-
# BATON_ACCESS_TOKEN: 'secret_token'
49+
# Snowflake connection configuration
50+
BATON_ACCOUNT_IDENTIFIER: ${{ secrets.BATON_ACCOUNT_IDENTIFIER }}
51+
BATON_USER_IDENTIFIER: ${{ secrets.BATON_USER_IDENTIFIER }}
52+
BATON_ACCOUNT_URL: ${{ secrets.BATON_ACCOUNT_URL }}
53+
BATON_PRIVATE_KEY: ${{ secrets.BATON_PRIVATE_KEY }}
5954
# The following parameters are passed to grant/revoke commands
6055
# Change these to the correct IDs for your test data
6156
CONNECTOR_GRANT: 'grant:entitlement:group:1234:member:user:9876'
@@ -69,37 +64,22 @@ jobs:
6964
uses: actions/setup-go@v5
7065
with:
7166
go-version-file: 'go.mod'
72-
# Install any dependencies here (or delete this)
73-
# - name: Install postgres client
74-
# run: sudo apt install postgresql-client
75-
# Run any fixture setup here (or delete this)
76-
# - name: Import sql into postgres
77-
# run: psql -h localhost --user postgres -f environment.sql
78-
# env:
79-
# PGPASSWORD: secretpassword
67+
8068
- name: Build baton-snowflake
81-
run: go build ./cmd/baton-snowflake
69+
run: go build -o baton-snowflake ./cmd/baton-snowflake
8270
# - name: Run baton-snowflake
8371
# run: ./baton-snowflake
8472

8573
- name: Install baton
8674
run: ./scripts/get-baton.sh && mv baton /usr/local/bin
8775

88-
# - name: Check for grant before revoking
89-
# run:
90-
# baton grants --entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --output-format=json | jq --exit-status ".grants[].principal.id.resource == \"${{ env.CONNECTOR_PRINCIPAL }}\""
91-
92-
# - name: Revoke grants
93-
# run: ./baton-snowflake --revoke-grant="${{ env.CONNECTOR_GRANT }}"
94-
95-
# - name: Check grant was revoked
96-
# run: ./baton-snowflake && baton grants --entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --output-format=json | jq --exit-status "if .grants then .grants[]?.principal.id.resource != \"${{ env.CONNECTOR_PRINCIPAL }}\" else . end"
97-
98-
# - name: Grant entitlement
99-
# # Change the grant arguments to the correct IDs for your test data
100-
# run: ./baton-snowflake --grant-entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --grant-principal="${{ env.CONNECTOR_PRINCIPAL }}" --grant-principal-type="${{ env.CONNECTOR_PRINCIPAL_TYPE }}"
101-
102-
# - name: Check grant was re-granted
103-
# run:
104-
# baton grants --entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --output-format=json | jq --exit-status ".grants[].principal.id.resource == \"${{ env.CONNECTOR_PRINCIPAL }}\""
76+
- name: Test Account Provisioning
77+
uses: ConductorOne/github-workflows/.github/actions/account-provisioning@main
78+
with:
79+
connector: './baton-snowflake'
80+
account-email: 'test-provisioning@example.com'
81+
account-login: 'test-provisioning-user'
82+
account-profile: '{"first_name": "Test", "last_name": "User", "name": "test-provisioning-user", "email": "test-provisioning@example.com"}'
83+
account-type: 'user'
84+
search-method: 'email'
10585

pkg/connector/connector.go

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,138 @@ func (d *Connector) Metadata(ctx context.Context) (*v2.ConnectorMetadata, error)
4848
return &v2.ConnectorMetadata{
4949
DisplayName: "Baton Snowflake",
5050
Description: "Connector syncing users, databases and account roles from Snowflake.",
51+
AccountCreationSchema: &v2.ConnectorAccountCreationSchema{
52+
FieldMap: map[string]*v2.ConnectorAccountCreationSchema_Field{
53+
"name": {
54+
DisplayName: "User Name",
55+
Required: true,
56+
Description: "The name of the user (required). Can be provided via login or profile.name",
57+
Placeholder: "username",
58+
Order: 0,
59+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
60+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
61+
},
62+
},
63+
"login": {
64+
DisplayName: "Login Name",
65+
Required: false,
66+
Description: "The login name for the user (defaults to email if not provided)",
67+
Placeholder: "user@example.com",
68+
Order: 1,
69+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
70+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
71+
},
72+
},
73+
"display_name": {
74+
DisplayName: "Display Name",
75+
Required: false,
76+
Description: "The display name for the user",
77+
Placeholder: "John Doe",
78+
Order: 2,
79+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
80+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
81+
},
82+
},
83+
"first_name": {
84+
DisplayName: "First Name",
85+
Required: false,
86+
Description: "The first name of the user",
87+
Placeholder: "John",
88+
Order: 3,
89+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
90+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
91+
},
92+
},
93+
"last_name": {
94+
DisplayName: "Last Name",
95+
Required: false,
96+
Description: "The last name of the user",
97+
Placeholder: "Doe",
98+
Order: 4,
99+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
100+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
101+
},
102+
},
103+
"email": {
104+
DisplayName: "Email",
105+
Required: false,
106+
Description: "The email address for the user",
107+
Placeholder: "user@example.com",
108+
Order: 5,
109+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
110+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
111+
},
112+
},
113+
"comment": {
114+
DisplayName: "Comment",
115+
Required: false,
116+
Description: "A comment or description for the user",
117+
Placeholder: "User description",
118+
Order: 6,
119+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
120+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
121+
},
122+
},
123+
"disabled": {
124+
DisplayName: "Disabled",
125+
Required: false,
126+
Description: "Whether the user account should be disabled",
127+
Order: 8,
128+
Field: &v2.ConnectorAccountCreationSchema_Field_BoolField{
129+
BoolField: &v2.ConnectorAccountCreationSchema_BoolField{},
130+
},
131+
},
132+
"must_change_password": {
133+
DisplayName: "Must Change Password",
134+
Required: false,
135+
Description: "Whether the user must change their password on next login",
136+
Order: 9,
137+
Field: &v2.ConnectorAccountCreationSchema_Field_BoolField{
138+
BoolField: &v2.ConnectorAccountCreationSchema_BoolField{},
139+
},
140+
},
141+
"default_warehouse": {
142+
DisplayName: "Default Warehouse",
143+
Required: false,
144+
Description: "The default warehouse to use when this user starts a session",
145+
Placeholder: "COMPUTE_WH",
146+
Order: 10,
147+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
148+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
149+
},
150+
},
151+
"default_namespace": {
152+
DisplayName: "Default Namespace",
153+
Required: false,
154+
Description: "The default namespace to use when this user starts a session",
155+
Placeholder: "DATABASE.SCHEMA",
156+
Order: 11,
157+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
158+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
159+
},
160+
},
161+
"default_role": {
162+
DisplayName: "Default Role",
163+
Required: false,
164+
Description: "The default role to use when this user starts a session",
165+
Placeholder: "PUBLIC",
166+
Order: 12,
167+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
168+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
169+
},
170+
},
171+
"default_secondary_roles": {
172+
DisplayName: "Default Secondary Roles",
173+
Required: false,
174+
Description: "The default secondary roles of this user to use when starting a session. Valid values: ALL or NONE. Default is ALL.",
175+
Placeholder: "ALL",
176+
Order: 13,
177+
Field: &v2.ConnectorAccountCreationSchema_Field_StringField{
178+
StringField: &v2.ConnectorAccountCreationSchema_StringField{},
179+
},
180+
},
181+
},
182+
},
51183
}, nil
52184
}
53185

0 commit comments

Comments
 (0)