Skip to content

Commit bd005b8

Browse files
authored
Add development section to readme (#2)
* Add development section to readme * If server principal's name looks like an email address, store it as an email address on the user trait * Add blurb to readme about required permissions and which tables are accessed.
1 parent e93e2b8 commit bd005b8

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,33 @@ It uses [go-mssqldb](https://github.com/microsoft/go-mssqldb) to connect to SQL
66
Check out [Baton](https://github.com/conductorone/baton) to learn more the project in general.
77

88
# Getting Started
9+
This connector requires that you connect to your SQL Server instance with a user with the proper access to read the system tables. The following permissions are required:
10+
- `VIEW ANY DEFINITION` on the server
11+
- `VIEW ANY DATABASE` on the server
12+
- `VIEW ANY DEFINITION` on each database
13+
- `VIEW SERVER STATE` on the server
14+
- `VIEW DATABASE STATE` on each database
15+
16+
The following tables are read while syncing data with this connector:
17+
- `sys.server_principals`
18+
- `sys.databases`
19+
- `sys.server_permissions`
20+
- `sys.server_role_members`
21+
- `sys.database_principals` on each database
22+
- `sys.database_role_members` on each database
923

1024
## brew
1125

1226
```
1327
brew install conductorone/baton/baton conductorone/baton/baton-sql-server
14-
baton-sql-server --dsn "server=127.0.0.1;user id=sa;password=P@ssw0rd;port=1433"
28+
baton-sql-server --dsn "server=127.0.0.1;user id=sa;password=devP@ssw0rd;port=1433"
1529
baton resources
1630
```
1731

1832
## docker
1933

2034
```
21-
docker run --rm -v $(pwd):/out -e BATON_DSN="server=127.0.0.1;user id=sa;password=P@ssw0rd;port=1433" ghcr.io/conductorone/baton-sql-server:latest -f "/out/sync.c1z"
35+
docker run --rm -v $(pwd):/out -e BATON_DSN="server=127.0.0.1;user id=sa;password=devP@ssw0rd;port=1433" ghcr.io/conductorone/baton-sql-server:latest -f "/out/sync.c1z"
2236
docker run --rm -v $(pwd):/out ghcr.io/conductorone/baton:latest -f "/out/sync.c1z" resources
2337
```
2438

@@ -27,7 +41,7 @@ docker run --rm -v $(pwd):/out ghcr.io/conductorone/baton:latest -f "/out/sync.c
2741
```
2842
go install github.com/conductorone/baton/cmd/baton@main
2943
go install github.com/conductorone/baton-sql-server/cmd/baton-sql-server@main
30-
baton-sql-server --dsn "server=127.0.0.1;user id=sa;password=P@ssw0rd;port=1433"
44+
baton-sql-server --dsn "server=127.0.0.1;user id=sa;password=devP@ssw0rd;port=1433"
3145
baton resources
3246
```
3347

@@ -42,6 +56,16 @@ baton resources
4256

4357
When fetching database permissions, the server principal backing the database principal will the resource that is granted entitlements.
4458

59+
# Development
60+
61+
A docker compose file is included to easily spin up a SQL Server instance for development. To start the instance, run:
62+
63+
```
64+
docker-compose up -d
65+
```
66+
67+
The instance will be available at `localhost:1433`. The default username is `sa` and the default password is `devP@ssw0rd`.
68+
4569
# Contributing, Support, and Issues
4670

4771
We started Baton because we were tired of taking screenshots and manually building spreadsheets. We welcome contributions, and ideas, no matter how small -- our goal is to make identity and permissions sprawl less painful for everyone. If you have questions, problems, or ideas: Please open a Github Issue!

pkg/connector/server_user.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package connector
22

33
import (
44
"context"
5+
"net/mail"
56

67
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
78
"github.com/conductorone/baton-sdk/pkg/annotations"
@@ -45,11 +46,17 @@ func (d *userPrincipalSyncer) List(ctx context.Context, parentResourceID *v2.Res
4546
status = v2.UserTrait_Status_STATUS_DISABLED
4647
}
4748

49+
userOpts := []resource.UserTraitOption{resource.WithStatus(status)}
50+
51+
if _, err = mail.ParseAddress(principalModel.Name); err == nil {
52+
userOpts = append(userOpts, resource.WithEmail(principalModel.Name, true))
53+
}
54+
4855
r, err := resource.NewUserResource(
4956
principalModel.Name,
5057
d.ResourceType(ctx),
5158
principalModel.ID,
52-
[]resource.UserTraitOption{resource.WithStatus(status)},
59+
userOpts,
5360
resource.WithParentResourceID(parentResourceID),
5461
)
5562
if err != nil {

0 commit comments

Comments
 (0)