Skip to content
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

Improve telemetry; more modular Auth API #149

Merged
merged 2 commits into from
Dec 5, 2018
Merged

Conversation

joshcanhelp
Copy link
Contributor

Changes

Add module Auth0::Mixins::Headers to handle telemetry headers more easily; add environmental telemetry (Ruby and Rails versions). This will make it easier to use Auth0::Api::AuthenticationEndpoints on its own like so:

class StaticPagesController < ApplicationController

  include Auth0::Api::AuthenticationEndpoints
  include Auth0::Mixins::HTTPProxy
  include Auth0::Mixins::Headers

  before_action :set_auth0_vars, only: %i[process_login_ro]

  def process_login_ro
    login_ro = params[:login_ro]
    response = login_with_resource_owner(login_ro[:email], login_ro[:password])
  end

  private

  def set_auth0_vars
    @domain = ENV['AUTH0_RUBY_DOMAIN']
    @client_id = ENV['AUTH0_RUBY_CLIENT_ID']
    @client_secret = ENV['AUTH0_RUBY_CLIENT_SECRET']
    @base_uri = "https://#{@domain}"
    @headers = client_headers
  end
end

References

This addresses an internal telemetry requirement while also making it easier to handle situations like this.

Testing

  • This change adds unit test coverage
  • This change has been tested on the latest version of Ruby

Checklist

  • All existing and new tests complete without errors
  • Rubocop passes on all added/modified files
  • All active GitHub checks have passed

@joshcanhelp joshcanhelp added this to the v4-Next milestone Dec 3, 2018
@joshcanhelp joshcanhelp changed the title Add telemetry Improve telemetry; more modular Auth API Dec 3, 2018
Copy link

@machuga machuga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall! Just nitpicking you :)


let(:base64_token) do
Base64.urlsafe_encode64('{"name":"ruby-auth0","version":"' + Auth0::VERSION + '"}')
let(:telemetry) do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to use {} syntax, as this repo seems to use more of a Weirich-style block syntax? (meaning it will also match the above)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@machuga - Fixed up!

@joshcanhelp joshcanhelp merged commit 3245a7e into master Dec 5, 2018
@joshcanhelp joshcanhelp deleted the add-telemetry branch December 5, 2018 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants