Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
How to integrate auth step into feathers service

I'm trying to integrate jwt/local auth into any call to feathers. So by including user/pass in any call it authorizes, rather than requiring a individual previous call to the /authorization endpoint and passing a header to subsequent calls. Ive tried using authenticate, but it doesnt see my auth strategies from within a hook. Here is the current create code, it does return the jwt token but how do i auth from here and integrate user data from the database into context like the auth generally would otherwise?

module.exports = (options = {}) => {
  return async (context) => {
    let promise = new Promise((resolve, reject) => {
      context.app
        .service("authentication")
        .create({
          username: context.data.username,
          password: context.data.password,
          strategy:"local"
        })
        .then((response) => {
          console.log(response)
          context.arguments[1]['Authorization'] = response.accessToken
          resolve(context);
        });
    });
    let result = await promise;
    if (result) {
      return context;
    }
  };
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The authenticate hook can take any strategy and will look for whatever you pass in params.authentication. In your example the following:

module.exports = (options = {}) => {
  return async (context) => {
    context.params = {
      ...context.params,
      authentication: {
        strategy: 'local',
        username: context.data.username,
        password: context.data.password
      }
    }
    
    return context;
  };
};

Would allow for authenticate('local') to run. If you want to get the authentication information from an HTTP request you can implement the parse(req, res) method in a custom strategy.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda