Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: use SpiceDB as a library #10

Merged
merged 1 commit into from
Jun 29, 2023
Merged

Conversation

vroldanbet
Copy link
Contributor

this shows how to use SpiceDB as a library
into a Go application. The example uses
the MemDB datastore, but any other
persistent datastore could be used.

Network: util.BufferedNetwork,
Enabled: true,
}),
server.WithPresharedSecureKey("foobar"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have a preshared key at all?

Copy link
Contributor Author

@vroldanbet vroldanbet Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSK is required for the server to start. I had a look and realized it's not required to set it in the client - when getting the dial context from the server itself, the PSK is set automatically for us. I've replaced foobar with uuid.NewString to make more obvious the PSK is irrelevant in this case, and added a comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do:

		server.WithGRPCAuthFunc(func(ctx context.Context) (context.Context, error) {
			return ctx, nil
		}),

to disable the auth check entirely

spicedb-as-library/main.go Outdated Show resolved Hide resolved
spicedb-as-library/main.go Outdated Show resolved Hide resolved
this shows how to use SpiceDB as a library
into a Go application. The example uses
the MemDB datastore, but any other
persistent datastore could be used.
Copy link
Contributor

@ecordell ecordell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vroldanbet vroldanbet merged commit 2bdaa41 into main Jun 29, 2023
@vroldanbet vroldanbet deleted the spicedb-as-library-example branch June 29, 2023 15:08
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants