mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-08 02:03:24 +00:00
refactor(server): remove obsolete auth header helpers (#40682)
This commit is contained in:
parent
5ea62ab05f
commit
cae7a139bc
2 changed files with 0 additions and 21 deletions
|
|
@ -2,10 +2,6 @@ export * as ServerAuth from "./auth"
|
|||
|
||||
import { Context, Layer, Option, Redacted } from "effect"
|
||||
|
||||
export type Credentials = {
|
||||
password?: string
|
||||
}
|
||||
|
||||
export type DecodedCredentials = {
|
||||
readonly username: string
|
||||
readonly password: Redacted.Redacted
|
||||
|
|
@ -37,16 +33,3 @@ export function authorized(credentials: DecodedCredentials, config: Info) {
|
|||
Redacted.value(credentials.password) === config.password.value
|
||||
)
|
||||
}
|
||||
|
||||
export function header(credentials?: Credentials) {
|
||||
const password = credentials?.password
|
||||
if (!password) return undefined
|
||||
|
||||
return `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`
|
||||
}
|
||||
|
||||
export function headers(credentials?: Credentials) {
|
||||
const authorization = header(credentials)
|
||||
if (!authorization) return undefined
|
||||
return { Authorization: authorization }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,3 @@ test("accepts only the fixed opencode username", () => {
|
|||
expect(ServerAuth.authorized({ username: "opencode", password: Redacted.make("secret") }, config)).toBe(true)
|
||||
expect(ServerAuth.authorized({ username: "custom", password: Redacted.make("secret") }, config)).toBe(false)
|
||||
})
|
||||
|
||||
test("encodes the fixed opencode username", () => {
|
||||
expect(ServerAuth.header({ password: "secret" })).toBe(`Basic ${Buffer.from("opencode:secret").toString("base64")}`)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue