GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/packages/opencode/src/server/auth.ts at dev · githubhjs/opencode Expand file tree/ Copy pathauth.tsMore file actions 48 lines (38 loc) · 1.58 KB / Copy pathauth.tsFile metadata and controls48 lines (38 loc) · 1.58 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 export * as ServerAuth from "./auth" import { ConfigService } from "@/effect/config-service" import { Flag } from "@opencode-ai/core/flag/flag" import { Config as EffectConfig, Context, Option, Redacted } from "effect" export type Credentials = { password?: string username?: string } export type DecodedCredentials = { readonly username: string readonly password: Redacted.Redacted } export class Config extends ConfigService.Service<Config>()("@opencode/ServerAuthConfig", { password: EffectConfig.string("OPENCODE_SERVER_PASSWORD").pipe(EffectConfig.option), username: EffectConfig.string("OPENCODE_SERVER_USERNAME").pipe(EffectConfig.withDefault("opencode")), }) {} export type Info = Context.Service.Shape<typeof Config> export function required(config: Info) { return Option.isSome(config.password) && config.password.value !== "" } export function authorized(credentials: DecodedCredentials, config: Info) { return ( Option.isSome(config.password) && credentials.username === config.username && Redacted.value(credentials.password) === config.password.value ) } export function header(credentials?: Credentials) { const password = credentials?.password ?? Flag.OPENCODE_SERVER_PASSWORD if (!password) return undefined const username = credentials?.username ?? Flag.OPENCODE_SERVER_USERNAME ?? "opencode" return `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}` } export function headers(credentials?: Credentials) { const authorization = header(credentials) if (!authorization) return undefined return { Authorization: authorization } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |