-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FCXPINFRA-76] Added Tiger token to requests #88
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM ruby:2.6.6 | ||
WORKDIR /app | ||
COPY Gemfile Gemfile | ||
COPY Gemfile.lock Gemfile.lock | ||
COPY little_monster.gemspec little_monster.gemspec | ||
RUN mkdir .git | ||
RUN mkdir -p lib/little_monster | ||
COPY lib/little_monster/version.rb lib/little_monster/version.rb | ||
RUN gem install bundler:2.3.16 | ||
RUN bundle install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
build: | ||
docker build -f Dockerfile.dev -t fury-little_monster-gem-dev . | ||
|
||
rspec: | ||
docker run -it -v .:/app fury-little_monster-gem-dev bundle exec rspec | ||
|
||
rubocop: | ||
docker run -it -v .:/app fury-little_monster-gem-dev bundle exec rubocop lib spec --format simple |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'jwt' | ||
require 'typhoeus' | ||
|
||
module LittleMonster | ||
module Tiger | ||
module API | ||
module_function | ||
|
||
def bearer_token | ||
token = new_shark_token | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. faltaría algun cacheo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, buscare alguna gema There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fijate que en fury-api ya lo hace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. es que ese es el cache de rails There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. una cosa a tener en cuenta es que no debería desaparecer el valor de la cache hasta no obtener el valor nuevo, aunque esté vencido. En rails nos pasó que se descartaba el valor almacenado en la cache (que aún era válido por varios minutos más) y luego no poder generar un nuevo token (o descargar un certificado) por un error temporal de red o la API |
||
"Bearer #{token}" if token | ||
end | ||
|
||
def new_shark_token | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hay instalaciones de LM API fuera de shark, quizas se puede agregar una config para no buscar el client credential de kubernetes y no ir a tiger (retornar directamente nil) A futuro estas instalaciones deberian hacer login mediante el client credential de tiger |
||
shark_token = File.read(LittleMonster.shark_login_file_path) | ||
response = make_call(:post, 'login/shark', body: { token: shark_token }.to_json) | ||
return nil if response.failure? | ||
|
||
MultiJson.load(response.body, symbolize_keys: true)[:token] | ||
end | ||
|
||
def make_call(method, endpoint, options = {}) | ||
Typhoeus::Request.new( | ||
"#{LittleMonster.tiger_api_url}/#{endpoint}", | ||
method: method, | ||
params: options[:params], | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: options[:body] | ||
).run | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colocar URL real
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en la configuración cuando la utilicen deberían agregar la url real
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el valor por defecto no debería ser la url real? para evitar problemas en los entornos donde no se configuró áun el valor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sobretodo porque por defecto tenemos la funcionalidad habilitada (enable_tiger_token:true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya que el api_url tampoco esta el original definido quise seguir esa linea, pero la puedo agregar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creo que mejor la agregan al momento de usarla, ya que puede ser para Meli, FaaP, Sulamerica, etc... en implementación tal vez la obtengan de una ENV