Skip to content

Conversation

@alexandrubagu
Copy link

@alexandrubagu alexandrubagu commented Feb 2, 2017

update mix deps to new ones and refactor a bunch of code

@alexandrubagu alexandrubagu changed the title update mix deps update mix deps & refactor code Feb 3, 2017
Copy link
Member

@doomspork doomspork left a comment

Choose a reason for hiding this comment

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

Thank you @alexandrubagu, I have some feedback for you. Let me know if you have any questions.

mix.exs Outdated
[{:jose, "~> 1.8"},
{:phoenix, "~> 1.2.0", optional: true},
{:plug, "~> 1.0"},
[{:jose, "~> 1.8.1"},
Copy link
Member

Choose a reason for hiding this comment

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

@alexandrubagu do we need to include the patch version? 1.8 should cover 1.8.x

Copy link
Author

Choose a reason for hiding this comment

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

That's right

defp assign_exp_from_ttl(the_claims, _), do: the_claims

end

Copy link
Member

Choose a reason for hiding this comment

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

Please remove extra whitespace.

Copy link
Author

Choose a reason for hiding this comment

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

I'm ok with this


@doc false
def ttl(%{"iat" => iat_v} = the_claims, requested_ttl) do
def ttl(the_claims = %{"iat" => iat_v}, requested_ttl) do
Copy link
Member

Choose a reason for hiding this comment

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

What this change necessary?

lib/guardian.ex Outdated
{headers, claims} = strip_value(claims, "headers", %{})
{secret, claims} = strip_value(claims, "secret")
{_, token} = secret
#tuple {header, claims}
Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning behind this change? Seems unnecessary.

lib/guardian.ex Outdated
stringify_params = stringify_keys(params)

#tuple {secret, params}
secret_params = strip_value(stringify_params, "secret")
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove the pattern matching?

Copy link
Member

Choose a reason for hiding this comment

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

Let's go back to using pattern matching here, it's not clear to me why it was removed in the first place. In fact the resulting code is worse without it, we're now reliant on using pipe chains within function calls to get the values we want.

@alexandrubagu
Copy link
Author

alexandrubagu commented Feb 6, 2017

After I've updated credo, I run mix credo this is the output:
guardian

So, I try to fix them. If you want to update deps to have the latest ones, I'm glad to make a new commit with required changes

Please let me know what are your intentions
Thanks

Copy link
Member

@doomspork doomspork left a comment

Choose a reason for hiding this comment

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

@alexandrubagu still a few more things we need to change before this PR is in a merge-able state.

lib/guardian.ex Outdated
stringify_params = stringify_keys(params)

#tuple {secret, params}
secret_params = strip_value(stringify_params, "secret")
Copy link
Member

Choose a reason for hiding this comment

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

Let's go back to using pattern matching here, it's not clear to me why it was removed in the first place. In fact the resulting code is worse without it, we're now reliant on using pipe chains within function calls to get the values we want.

lib/guardian.ex Outdated
try do
with {:ok, claims} <- decode_token(jwt, secret),
{:ok, verified_claims} <- verify_claims(claims, params),
with {:ok, claims} <- decode_token(jwt, secret_params |> elem(0)),
Copy link
Member

Choose a reason for hiding this comment

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

We do not want to use pipes inside function calls, this is messy.

@alexandrubagu
Copy link
Author

I've revert changes and set some credo checking rules to false

@doomspork
Copy link
Member

Thank you @alexandrubagu! I'll look over this later this evening and we get it merged if we're all good to go 👍

@hassox feel free to take a peek at this.

@snewcomer
Copy link

@doomspork Any updates on this? What about upgrading to phoenix 1.3.0-rc.0 as well?

@doomspork
Copy link
Member

@snewcomer I still need to look through this PR but we are not making changes for 1.3rc, please see the previous threads on the topic: #276

mix.exs Outdated
[{:jose, "~> 1.8"},
{:phoenix, "~> 1.2.0", optional: true},
{:plug, "~> 1.0"},
{:phoenix, "~> 1.2.1", optional: true},
Copy link
Member

Choose a reason for hiding this comment

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

@alexandrubagu could we update this to: {:phoenix, "~> 1.2", optional: true}? I believe it'll address most of the 1.3rc1 concerns at the same time 👍

Copy link
Author

Choose a reason for hiding this comment

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

Done 👍

@doomspork
Copy link
Member

Thank you @alexandrubagu!

@doomspork doomspork requested review from hassox and scrogson March 22, 2017 21:15
@doomspork
Copy link
Member

@hassox / @scrogson any final comments before I merge?

@doomspork
Copy link
Member

Thank you again @alexandrubagu and apologizes for the delays.

@doomspork doomspork merged commit fa041f0 into ueberauth:master Mar 22, 2017
@alexandrubagu
Copy link
Author

No problem

Hanspagh pushed a commit to Hanspagh/guardian that referenced this pull request Nov 1, 2017
* update mix deps

* add new credo config

* refactor code to pass new credo specs

* add jose 1.8.1 which fix warnings on elixir 1.4

* revert to parttern matching

* set some checks to false because needs refactor

* update to phoenix 1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants