https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • s

    sirhype

    03/28/2023, 9:43 AM
    I'll check it out, thank you!
  • y

    Yacine Hmito

    03/28/2023, 11:38 AM
    Thank you very much. In our context, we don't intended to let users publish their own code. It's internal stuff. We still want to have that layer of security though. I don't really want the engineers in team A to bind to a worker managed by team B without team B explicitly allowing it.
  • h

    HardAtWork

    03/28/2023, 11:40 AM
    Ok, so this might be a little bit hacky, but if you use a system like GH Actions, and have it output the bindings, then someone has to approve the bindings before it is deployed?
  • s

    Skye

    03/28/2023, 11:42 AM
    Yeah there's nothing native that would let you do that, you'd need your own deploy workflow
  • y

    Yacine Hmito

    03/28/2023, 11:43 AM
    That's a great idea.
  • y

    Yacine Hmito

    03/28/2023, 11:43 AM
    Still looking for something like a runtime check.
  • h

    HardAtWork

    03/28/2023, 11:46 AM
    The issue there is that CF has no concept of script ownership. Scripts are owned by the account, so there isn’t anyway to test/enforce a team having access to only specific bindings
  • y

    Yacine Hmito

    03/28/2023, 11:49 AM
    The use case is a bit more complex than this actually. We have multiple services on Cloudflare Workers and want service-to-service communication. So far we're doing this with service bindings and it works well. The problem is scaling this up with environments. Which environment to use for which requests depends on the customer being served. That's a somewhat complex logic that we are offloading to a single service called "the Dispatcher". So now, instead of having service A binding to service B, we would have service A binding to the Dispatcher and the Dispatcher binding to the many environments of service B. When service A wants to call service B, it does a
    fetch
    to the Dispatcher with a URL that locates service B. It's up to the Dispatcher to route it to the appropriate environment. Now, I want a secure this by ensuring that every service is only callable from the Dispatcher. There are two layers of control: - Statically: Ensuring that an arbitrary binding cannot be set on a worker. For this you provided some good answers. - Dynamically: Validating that the request indeed comes from the Dispatcher. Short of singing the whole request, I don't how to do this.
  • h

    HardAtWork

    03/28/2023, 11:49 AM
    So the best you can do is ensure every script runs through a single deployment pipeline, and then have that pipeline enforce the restrictions
  • y

    Yacine Hmito

    03/28/2023, 11:49 AM
    So, I am not really looking for a builtin way to do this, but wondering if anybody has experience in doing service-to-service authentication.
  • y

    Yacine Hmito

    03/28/2023, 11:50 AM
    That's exactly the plan. People can still set a binding manually through the web interface though. I'd have to lock that down (probably not a bad idea in of itself though).
  • h

    HardAtWork

    03/28/2023, 11:50 AM
    You could just have a header that enforces the id of the sender
  • y

    Yacine Hmito

    03/28/2023, 11:51 AM
    Any service would have knowledge of the ID though.
  • y

    Yacine Hmito

    03/28/2023, 11:51 AM
    I know it might sound paranoid. 😅
  • y

    Yacine Hmito

    03/28/2023, 11:52 AM
    There's no perfect way to do it for sure. I think I am just missing some policy enforcement on Cloudflare proper and need to make my peace with this.
  • y

    Yacine Hmito

    03/28/2023, 11:53 AM
    Thank you very much for the ideas though.
  • k

    Klowner

    03/28/2023, 5:25 PM
    Anyone know where I might find an example of using bound service workers with jest-environment-miniflare? I'm assuming it has something to do with mounts but I'm a bit lost.
  • k

    Klowner

    03/28/2023, 5:31 PM
    assuming it's even possible 🤔
  • k

    Klowner

    03/28/2023, 5:52 PM
    ah, miniflare apparently doesn't support nested mounts anyway, guess I'll just mock it out
  • a

    avi

    03/28/2023, 8:21 PM
  • a

    avi

    03/28/2023, 8:21 PM
    do typescript sourcemaps not work for workers in
    debug
    mode?
  • b

    BBM

    03/28/2023, 8:39 PM
    Is it possible to connect to MongoDB directly (not through app services on Atlas) from a Worker? It didn't even occur to me that it might not be possible before I started going down this path
  • k

    kian

    03/28/2023, 8:41 PM
    Workers only talk HTTP and WebSockets, so you always need a HTTP proxy in-front
  • a

    avi

    03/28/2023, 11:19 PM
    hey, i think i found a bug in miniflare...
    Copy code
    js
    export class Counter {
      constructor() {
        setInterval(() => console.log(Date.now()), 1000);
      }
    
      async fetch() {
        return new Response('Hello, world!');
      }
    }
  • a

    avi

    03/28/2023, 11:20 PM
    wrangler dev --local --persist counter.js
    --> every second, the current time is printed
    wrangler dev --experimental-local --persist counter.js
    --> every second, the time printed NEVER CHANGES
  • a

    avi

    03/28/2023, 11:20 PM
    is this a known limitation?
  • k

    kian

    03/28/2023, 11:20 PM
    Date.now() is Spectre-safe in real Workers
  • k

    kian

    03/28/2023, 11:21 PM
    If you’re not doing I/O, it doesn’t update
  • a

    avi

    03/28/2023, 11:21 PM
    😮
  • a

    avi

    03/28/2023, 11:21 PM
    if there some documentation on that? or tips on how to work around?
1...236323642365...2509Latest