GithubHelp home page GithubHelp logo

cores-hapi's People

Contributors

tillre avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

iotaweb

cores-hapi's Issues

How to handle users only updating their own documents

Hi Till,

I'm coming to grips with the permissions side of cores-hapi and have the basic CRUD actions working, i.e.

permissions: {                    
  Resource: { 
    load: true,
    create: true,
    update: true,
    destroy: true,
    views: true 
  }
}

However, I'm not quite sure how to handle allowing users to only update their own documents, i.e. by storing their user id as a document property and then only allowing update or destroy actions if this matches the id of the authenticated user.

If I understand cores-hapi correctly, this level of control is not built in, so presumably would need to be extended to support this? Am I correct in assuming that, and if so, do you have any suggestions as how to do this. Or have I overlooked something fundamental.

Any thoughts or ideas appreciated :)

Regards, Rob

Allow anonymous access to _index?

Hi Till,

I've added authentication to my API server and noticed that I was getting 401s in my Angular app when retrieving /_index. As Hapi only authorises authenticated users, I overcame this by changing the auth mode to allow 'try' in /cores-hapi/lib/create-api.js, e.g.:

    // GET resources index
    {
      method: 'GET',
      path: basePath + '/_index',
      config: {
        auth: {
            mode: 'try'
        },
        handler: function() {
          this.reply(index);
        }
      }
    },

My patch is forked here: iotaweb@42b16e9

I didn't want to submit a PR as I wanted to make sure it wasn't something I had overlooked. Naturally, this wouldn't apply if the API is not secured (but 'try' mode allows for anonymous or authenticated users).

Regards, Rob

How to allow anonymous access to some resources

OK, I hope this is my last question about authorisation :)

How would I go about providing anonymous to some resources, while securing others. Or indeed, only protecting some actions, e.g. create, update and destroy whilst allowing anonymous access to load and views.

As your library takes care of the route configuration, I'm not sure how to handle these exceptions. An thoughts or ideas much appreciated.

Cheers, Rob

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.