Friday 9 June 2017

trying to establish a cookie auth strategy with hapi-auth-cookie

so I'm trying to get a cookie based strategy with hapi-auth-cookie and it seems to work at some extend, I'm able to register users and log in (technically) but when I try to hit an endpoint that requires authentication I get Unauthorized: Missing Authentication The strategy config is

server.auth.strategy('session', 'cookie', {
    password: 'secretpasswordforencryption',
    cookie: 'cookie',
    ttl: 24 * 60 * 60 * 1000, // Set session to 1 day
    isSecure: false
  });

The handler has this config:

auth: {
    mode:'required',
    strategy:'session',
    scope: ['admin']
  },

And I'm making the request with Vuejs/vue-resource like this:

    this.$http.post('https://urlto.api/v1/student', {name :'koyczan', account: '123123'})
    .then(response => {console.log(response)})

Is there something I'm not doing?

Thanks in advance



via ZSnake

No comments:

Post a Comment