Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
PORT: '8080'
AUTH_SERVER_URL: http://localhost:5312
AUTH_SERVER_ISSUER: http://auth-api:5312
API_SERVICE_TOKEN: verify-dev-service-token-not-a-real-secret
SEAMLESS_SERVICE_TOKEN: verify-dev-service-token-not-a-real-secret
COOKIE_SIGNING_KEY: verify-dev-service-token-not-a-real-secret
JWKS_KID: dev-main
run: |
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use serde_json::json;
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let auth = Adapter::builder(std::env::var("AUTH_SERVER_URL")?)
.cookie_secret(std::env::var("COOKIE_SECRET")?) // at least 32 bytes
.service_secret(std::env::var("SERVICE_SECRET")?) // the API's API_SERVICE_TOKEN
.service_secret(std::env::var("SEAMLESS_SERVICE_TOKEN")?) // same value as the API's API_SERVICE_TOKEN
.jwks_kid(std::env::var("JWKS_KID")?)
.build()?;

Expand All @@ -60,6 +60,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```

The auth server reads the service token from `API_SERVICE_TOKEN` and your app reads it from
`SEAMLESS_SERVICE_TOKEN`; both hold the same value.

Serve with `into_make_service_with_connect_info::<SocketAddr>()`. Without it the adapter has no
peer address and forwards no client address to the auth API.

Expand Down Expand Up @@ -93,7 +96,7 @@ JSON it would be a sign-in the user never made. The client SDKs already send JSO
| `auth_server_issuer` | the URL | Expected `iss` of the API's tokens, when it differs from the URL you reach it at |
| `audience` | the issuer | Expected `aud` of the API's tokens |
| `cookie_secret` | required | Signs the session cookies (32 bytes or more) |
| `service_secret` | required | The API's `API_SERVICE_TOKEN` (32 bytes or more) |
| `service_secret` | required | The service token, read from `SEAMLESS_SERVICE_TOKEN` in the examples; the same value as the API's `API_SERVICE_TOKEN` (32 bytes or more) |
| `jwks_kid` | `dev-main` | `kid` header on service tokens |
| `cookie_domain` | none | Cookie `Domain` |
| `insecure_cookies` | `false` | Drops `Secure`, for local development over HTTP |
Expand Down Expand Up @@ -180,7 +183,7 @@ Docker, a checkout of `seamless-auth-api` and the `seamless` CLI:

```bash
PORT=8080 AUTH_SERVER_URL=http://localhost:5312 AUTH_SERVER_ISSUER=http://auth-api:5312 \
API_SERVICE_TOKEN=verify-dev-service-token-not-a-real-secret \
SEAMLESS_SERVICE_TOKEN=verify-dev-service-token-not-a-real-secret \
COOKIE_SIGNING_KEY=verify-dev-service-token-not-a-real-secret JWKS_KID=dev-main \
cargo run --example refapp &

Expand Down
2 changes: 1 addition & 1 deletion conformance/refapp/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn main() {
let auth = Adapter::builder(env("AUTH_SERVER_URL"))
.auth_server_issuer(env("AUTH_SERVER_ISSUER"))
.cookie_secret(env("COOKIE_SIGNING_KEY"))
.service_secret(env("API_SERVICE_TOKEN"))
.service_secret(env("SEAMLESS_SERVICE_TOKEN"))
.jwks_kid(env("JWKS_KID"))
.deliver(move |d: Delivery| {
let sink = sink.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let auth = Adapter::builder(std::env::var("AUTH_SERVER_URL")?)
//! .cookie_secret(std::env::var("COOKIE_SECRET")?)
//! .service_secret(std::env::var("SERVICE_SECRET")?)
//! .service_secret(std::env::var("SEAMLESS_SERVICE_TOKEN")?)
//! .jwks_kid(std::env::var("JWKS_KID")?)
//! .build()?;
//!
Expand Down
5 changes: 3 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ impl Builder {
self
}

/// Signs the service tokens the auth API trusts this adapter by. It is the
/// API's `API_SERVICE_TOKEN`. At least 32 bytes. Required.
/// Signs the service tokens the auth API trusts this adapter by. It holds the
/// same value as the API's `API_SERVICE_TOKEN`; apps conventionally read it
/// from `SEAMLESS_SERVICE_TOKEN`. At least 32 bytes. Required.
pub fn service_secret(mut self, secret: impl Into<String>) -> Self {
self.service_secret = secret.into();
self
Expand Down
Loading