MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeLocalIdentityLayer

Function makeLocalIdentityLayer

apps/local/src/identity.ts:73–84  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

71 * it once at boot like self-host's.
72 */
73export const makeLocalIdentityLayer = (token: string): Layer.Layer<IdentityProvider> =>
74 Layer.succeed(IdentityProvider)(
75 IdentityProvider.of({
76 authenticate: (request) => {
77 if (isUnauthenticatedCallback(request)) return Effect.succeed(LOCAL_PRINCIPAL);
78 const presented = bearerToken(request.headers);
79 return presented !== undefined && safeEqual(presented, token)
80 ? Effect.succeed(LOCAL_PRINCIPAL)
81 : Effect.fail(new Unauthorized());
82 },
83 }),
84 );

Callers 2

authenticateFunction · 0.90
makeLocalApiHandlerFunction · 0.90

Calls 3

safeEqualFunction · 0.90
bearerTokenFunction · 0.70

Tested by 1

authenticateFunction · 0.72