Skip to main content

SECRET_KEY_BASE

Constant SECRET_KEY_BASE 

Source
pub const SECRET_KEY_BASE: &str = "SECRET_KEY_BASE";
Expand description

Name of the Worker secret the session encryption key is derived from: SECRET_KEY_BASE.

It must be at least 64 characters. ocre secret generates one, ocre new writes a local one to .dev.vars, and ocre deploy uploads the production one. Without it, requests that read an existing session cookie or change the session fail with Error::Internal naming this fix. jwt derives its signing key from the same secret.

ยงExamples

use axum::extract::State;
use ocre::{Ctx, Result, SECRET_KEY_BASE};

async fn secret_is_set(State(ctx): State<Ctx>) -> Result<String> {
    Ok(ctx.env().secret(SECRET_KEY_BASE).is_ok().to_string())
}