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

Need to use symbolize_keys everywhere! #330

Closed
rabajaj0509 opened this issue Sep 9, 2019 · 2 comments
Closed

Need to use symbolize_keys everywhere! #330

rabajaj0509 opened this issue Sep 9, 2019 · 2 comments

Comments

@rabajaj0509
Copy link
Contributor

rabajaj0509 commented Sep 9, 2019

I am trying to use the jwks_loader function which looks something like:

    response = RestClient::Request.execute(
      :url => Setting['oidc_jwks_url'],
      :method => :get,
      :verify_ssl => true
    )
    jwks_keys = JSON.parse(response)['keys']
    { keys: jwks_keys.map(&:symbolize_keys) }

I don't like the fact that I need to use the symbolize_keys(rails method), can we check if the keys for the hash has symbols or strings, if strings then we can convert them into symbols.

I am not sure if this even makes any sense, but if it looks reasonable and valid then I would like to contribute to it :)

@rabajaj0509 rabajaj0509 changed the title Need to symbolize_keys everywhere! Need touse symbolize_keys everywhere! Sep 9, 2019
@rabajaj0509 rabajaj0509 changed the title Need touse symbolize_keys everywhere! Need to use symbolize_keys everywhere! Sep 9, 2019
@jtara
Copy link

jtara commented Sep 9, 2019

You could use:

jwks_keys.with_indifferent_access

https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html

You would need to load ActiveSupport. If you've a Rails project, it's already there.

If not Rails, you may need to add ActiveSupport as I do in my Sinatra-based API work.

I don't think it would be good to change it internally, as it would create a dependency on ActiveSupport.

@excpt
Copy link
Member

excpt commented Sep 16, 2019

I agree with @jtara. This is an implementation detail specific to the application of @rahulbajaj0509. The ActiveSupport dependency won't be introduced.

@excpt excpt closed this as completed Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants