pub struct SpiceDbConfig {
pub endpoint: String,
pub token: Option<String>,
}Expand description
Configuration for connecting to a SpiceDB instance.
SpiceDbConfig contains the necessary connection parameters for establishing
a gRPC connection to SpiceDB. It supports configuration via environment variables
or command-line arguments using clap.
§Configuration Methods
You can configure SpiceDB connection in three ways:
- Directly in code - Create the struct manually
- Environment variables - Set
SPICEDB_ENDPOINTandSPICEDB_TOKEN - Command-line arguments - Use
--spicedb-endpointand--spicedb-token
§Examples
§Manual configuration
use authz::SpiceDbConfig;
let config = SpiceDbConfig {
endpoint: "localhost:50051".to_string(),
token: Some("your-preshared-key".to_string()),
};§From environment variables
export SPICEDB_ENDPOINT="grpc.authzed.com:443"
export SPICEDB_TOKEN="your-preshared-key"use authz::SpiceDbConfig;
use clap::Parser;
let config = SpiceDbConfig::parse();§From command-line arguments
cargo run -- --spicedb-endpoint localhost:50051 --spicedb-token mykey§Security Note
The token field contains a sensitive preshared key. Ensure it is:
- Never hardcoded in version control
- Stored securely (e.g., environment variables, secrets manager)
- Transmitted only over secure connections (TLS/SSL)
Fields§
§endpoint: StringThe SpiceDB endpoint URL.
This should be the gRPC endpoint of your SpiceDB server, including the port. The scheme (http:// or https://) is optional and will be added automatically if not present.
§Examples
"localhost:50051"- Local development"grpc.authzed.com:443"- AuthZed managed service"spicedb.example.com:443"- Custom deployment
§Environment Variable
Can be set via SPICEDB_ENDPOINT environment variable.
§Default
Defaults to "localhost:50051" if not specified.
token: Option<String>The preshared key for authenticating with SpiceDB.
This is a secret token used to authenticate your application with the
SpiceDB server. If None, the connection will be made without authentication
(useful for local development with SpiceDB running in insecure mode).
§Security
This token grants access to your authorization data. Keep it secure:
- Never commit it to version control
- Use environment variables or a secrets manager
- Rotate it regularly
- Use different tokens for different environments
§Environment Variable
Can be set via SPICEDB_TOKEN environment variable.
§Examples
use authz::SpiceDbConfig;
// With authentication
let secure_config = SpiceDbConfig {
endpoint: "grpc.authzed.com:443".to_string(),
token: Some("tc_my_secret_token_abc123".to_string()),
};
// Without authentication (local dev only)
let local_config = SpiceDbConfig {
endpoint: "localhost:50051".to_string(),
token: None,
};Trait Implementations§
Source§impl Args for SpiceDbConfig
impl Args for SpiceDbConfig
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl Clone for SpiceDbConfig
impl Clone for SpiceDbConfig
Source§fn clone(&self) -> SpiceDbConfig
fn clone(&self) -> SpiceDbConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CommandFactory for SpiceDbConfig
impl CommandFactory for SpiceDbConfig
Source§impl Debug for SpiceDbConfig
impl Debug for SpiceDbConfig
Source§impl FromArgMatches for SpiceDbConfig
impl FromArgMatches for SpiceDbConfig
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Parser for SpiceDbConfig
impl Parser for SpiceDbConfig
Source§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
Source§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
Source§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
Auto Trait Implementations§
impl Freeze for SpiceDbConfig
impl RefUnwindSafe for SpiceDbConfig
impl Send for SpiceDbConfig
impl Sync for SpiceDbConfig
impl Unpin for SpiceDbConfig
impl UnwindSafe for SpiceDbConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request