GithubHelp home page GithubHelp logo

Comments (11)

keyvan-m-sadeghi avatar keyvan-m-sadeghi commented on May 30, 2024 1

Hi @hosnas, @Arvant has sent a pull request, #59, that I think addresses this issue. Appreciate if you could confirm.

from agenda-rest.

sampathBlam avatar sampathBlam commented on May 30, 2024 1

@keyvan-m-sadeghi : I have added another PR #60 with a very cosmetic change regarding the Error message in case of incorrect API key.

from agenda-rest.

hosnas avatar hosnas commented on May 30, 2024 1

@keyvan-m-sadeghi can confirm it works as intended. Great job @Arvant and @sampathBlam 👍

I just want to say its worth mentioning it in the readme doc.

from agenda-rest.

keyvan-m-sadeghi avatar keyvan-m-sadeghi commented on May 30, 2024 1

Agreed, @Arvant and @sampathBlam, any help with documenting this is very much appreciated.

from agenda-rest.

sampathBlam avatar sampathBlam commented on May 30, 2024 1

The current implementation with the API key looks neat and sufficient. A more robust way to authenticate would be to handle in-house OAuth2 based authentication with Client credentials strategy. As agenda-rest might be predominantly used in machine-to-machine communications (users wont directly hit the hosted agenda-rest service), it makes sense for the clients(may be another server or an application) that interact with agenda-rest to get a client ID and secret as part of a registration process, then get an application access token and use it for any further requests. @hosnas , @keyvan-m-sadeghi , @Arvant : Your thoughts on this?

from agenda-rest.

sampathBlam avatar sampathBlam commented on May 30, 2024 1

@keyvan-m-sadeghi : Yes I agree. Adding OAuth would mean increasing unnecessary complexity and would prove a hindrance in maintaining agenda as a microservice.

from agenda-rest.

geosp avatar geosp commented on May 30, 2024 1

@keyvan-m-sadeghi Thank you for accepting my suggestion. I will call the header x-agenda-signature and it will be optionally enabled via settings and a flag. While I implement this feature can you please publish and bump the version for me. I have an internal project that depends on PR #70. Thank you so much for your prompt response.

from agenda-rest.

keyvan-m-sadeghi avatar keyvan-m-sadeghi commented on May 30, 2024

@sampathBlam you're absolutely right, main use case for agenda-rest is M2M interactions. As such, I'm not clear on the reason for adding complexities like a refresh token. What's the added value? In addition, I'm very much for agenda-rest remaining a microservice, wouldn't adding this be a practice used in monoliths?

from agenda-rest.

geosp avatar geosp commented on May 30, 2024

I think is worth considering to adopt the same strategy GitHub uses to secure web-hooks. This strategy is much more secure that passing an none encrypted key. For more documentation please take a look at this https://developer.github.com/webhooks/securing. Here is some example code that shows how to validate the request you could also implement a middle-ware using this approach:

export let validateGithubRequest = ({ secret, req }) => {
  let signature = req.headers['x-hub-signature']
  let hmac = createHmac('sha1', secret)
  let body = Buffer.from(req.rawBody)
  hmac.update(body, 'utf-8')
  return signature === `sha1=${hmac.digest('hex')}`
}
.
.
.
let preserveRawBody = (req, res, bodyBuffer) => {
  req.rawBody = bodyBuffer.toString('utf8')
}

.
.
.
  const app = express(feathers())
  app
    .configure(express.rest(rest()))
    .configure(socketio())
    .configure(prometheus)
    .use(bodyParser.json({ limit: '50mb', verify: preserveRawBody }))
.
.
.

@keyvan-m-sadeghi Let me know what you think and I can implement a PR that exemplifies what I'm proposing.

from agenda-rest.

keyvan-m-sadeghi avatar keyvan-m-sadeghi commented on May 30, 2024

@geosp seems like a fine solution, I suggest that we keep the x-api-key as it still might be the preferred method for some. I'll wait for your PR, then publish to npm and bump up the version.

from agenda-rest.

keyvan-m-sadeghi avatar keyvan-m-sadeghi commented on May 30, 2024

@geosp done 🎉

from agenda-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.