summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authoropencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>2026-04-24 21:13:00 +0000
committeropencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>2026-04-24 21:13:00 +0000
commit7a02eee0f4002687a5167574744cd00cb06624c4 (patch)
tree65cfbe168f10b5ee65f6c3258c8edbf9c8830ecb /packages
parentcf45a8d80752fd4f29a57c6b696c40c3b332c3e9 (diff)
downloadopencode-7a02eee0f4002687a5167574744cd00cb06624c4.tar.gz
opencode-7a02eee0f4002687a5167574744cd00cb06624c4.zip
chore: generate
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/server/routes/instance/httpapi/auth.ts43
1 files changed, 24 insertions, 19 deletions
diff --git a/packages/opencode/src/server/routes/instance/httpapi/auth.ts b/packages/opencode/src/server/routes/instance/httpapi/auth.ts
index adddcc4be..fe72b7822 100644
--- a/packages/opencode/src/server/routes/instance/httpapi/auth.ts
+++ b/packages/opencode/src/server/routes/instance/httpapi/auth.ts
@@ -8,13 +8,16 @@ class Unauthorized extends Schema.TaggedErrorClass<Unauthorized>()(
{ httpApiStatus: 401 },
) {}
-export class Authorization extends HttpApiMiddleware.Service<Authorization>()("@opencode/ExperimentalHttpApiAuthorization", {
- error: Unauthorized,
- security: {
- basic: HttpApiSecurity.basic,
- authToken: HttpApiSecurity.apiKey({ in: "query", key: "auth_token" }),
+export class Authorization extends HttpApiMiddleware.Service<Authorization>()(
+ "@opencode/ExperimentalHttpApiAuthorization",
+ {
+ error: Unauthorized,
+ security: {
+ basic: HttpApiSecurity.basic,
+ authToken: HttpApiSecurity.apiKey({ in: "query", key: "auth_token" }),
+ },
},
-}) {}
+) {}
const emptyCredential = {
username: "",
@@ -39,19 +42,21 @@ function validateCredential<A, E, R>(
}
function decodeCredential(input: string) {
- return Encoding.decodeBase64String(input).asEffect().pipe(
- Effect.match({
- onFailure: () => emptyCredential,
- onSuccess: (header) => {
- const parts = header.split(":")
- if (parts.length !== 2) return emptyCredential
- return {
- username: parts[0],
- password: Redacted.make(parts[1]),
- }
- },
- }),
- )
+ return Encoding.decodeBase64String(input)
+ .asEffect()
+ .pipe(
+ Effect.match({
+ onFailure: () => emptyCredential,
+ onSuccess: (header) => {
+ const parts = header.split(":")
+ if (parts.length !== 2) return emptyCredential
+ return {
+ username: parts[0],
+ password: Redacted.make(parts[1]),
+ }
+ },
+ }),
+ )
}
export const authorizationLayer = Layer.succeed(