Authenticated Incoming Webhook to Python script

So I found this in the docs https://pipedream.com/@dylburger/protect-an-http-endpoint-with-basic-auth-p_pWCYAez/edit

This is essentially exactly what I am looking for. However, it doesn’t allow me to run Python code as a next step in the workflow and I can’t seem to determine how to replicate this in V2? Any thoughts?

Welcome @hjohnson ! Yes, we need to update that public workflow for v2 (we don’t yet support public v2 workflows, but it’s on the near-term backlog).

For now, this code should work within a Node.js v2 code step:

export default defineComponent({
  props: {
    user: {
      type: "string",
      label: "Username",
      secret: true,
    },
    password: {
      type: "string",
      label: "Password",
      secret: true,
    }
  },
  async run({ steps, $ }) {
    if (!steps.trigger.event.headers.authorization) {
      reject()
      $end("No Authorization header present")
    }

    // The data in the Authorization header looks like this:
    // Basic <base64-encoded-username-and-password>
    // Parse and decode it
    const authData = Buffer.from(steps.trigger.event.headers.authorization.split(" ")[1] || "", 'base64').toString()
    if (!authData) {
      await reject()
      $end("No data in Authorization header")
    }

    // Validate the username and password with those configured in params
    const [user, pass] = authData.split(":")
    if (user !== this.user || pass !== this.password) {
      reject()
      $end("Username / password don't match")
    }

    // If we've reached this point, we've validated the Authorization header!
    await $.respond({
      status: 200,
      body: "Successfully authenticated"
    })

    async function reject() {
      await $.respond({
        status: 401,
      })
    }
  },
})

Then you should be able to run a Python step after.

Thank you sir! I will give it a go!