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

Guardian.Plug.sign_in is not injecting permissions #47

Closed
Pjino opened this issue Sep 14, 2015 · 11 comments
Closed

Guardian.Plug.sign_in is not injecting permissions #47

Pjino opened this issue Sep 14, 2015 · 11 comments

Comments

@Pjino
Copy link

Pjino commented Sep 14, 2015

I'm using and updated version of the Guardian example it seems that whatever combination of permissions I try to inject (for instance, "Guardian.Plug.sign_in(user, :token, perms: %{ default: :write_profile })" it won work.
When inspecting claims I always see: ..."pem" => %{"default" => -1},

@Pjino Pjino changed the title Guardian.Plug.sign_in is not injection permissions Guardian.Plug.sign_in is not injecting permissions Sep 14, 2015
@hassox
Copy link
Member

hassox commented Sep 14, 2015

Hi @Pjino. What version are you currently using? Can I see your config for guardian?

@Pjino
Copy link
Author

Pjino commented Sep 14, 2015

Hi @hassox. I'm using the latest version of everything (Guardian, Phoenix,...) and I (think) I made all the necessary changes.
My config.exs looks like this:
screen shot 2015-09-14 at 22 09 52
and my controller is:
screen shot 2015-09-14 at 22 11 53

@hassox
Copy link
Member

hassox commented Sep 14, 2015

Thanks. Just an FYI you have two hooks declared.

The reason you're seeing the -1 is because you're setting the default permissions to Guardian.Permissions.max in sign in. If you had this instead do you still see -1?

Guardian.Plug.sign_in(user, :token, perms: %{ default: [:write_profile] })

@Pjino
Copy link
Author

Pjino commented Sep 15, 2015

I changed it to:
Guardian.Plug.sign_in(user, :token, perms: %{ default: [:write_profile] })
screen shot 2015-09-15 at 09 52 26
and:
Guardian.Plug.sign_in(user, :token, perms: %{ default: [:read_profile, :write_profile] })
screen shot 2015-09-15 at 08 51 24
And it still's the same. I even created new users for each case but nothing changed.
screen shot 2015-09-15 at 08 39 55
screen shot 2015-09-15 at 08 52 54
My hooks are:
screen shot 2015-09-15 at 08 55 26

@yuyabee
Copy link
Contributor

yuyabee commented Sep 18, 2015

I think I'm seeing the same issue.
In IEx, Guardian.Permissions.to_value [:read_profile, :write_profile], :default returns 0, and Guardian.Permissions.availble returns [] where it's supposed to return list of permissions.
I have exact the same configuration as the permission example in the document.
@Pjino please try these functions and see if we are talking about the same problem.

@Pjino
Copy link
Author

Pjino commented Sep 18, 2015

@yuyabee Yes, Guardian.Permissions.to_value [:read_profile, :write_profile], :default returns 0 and Guardian.Permissions.availble returns an error: UndefinedFunctionError

@yuyabee
Copy link
Contributor

yuyabee commented Sep 18, 2015

@Pjino Sorry, that was a typo, it's Guardian.Permissions.available

@Pjino
Copy link
Author

Pjino commented Sep 18, 2015

@yuyabee Yes, it returns []. Sorry for testing it in such a rush that I didn't even try to see why it returned undefined...It was obvious:)

@hassox
Copy link
Member

hassox commented Sep 20, 2015

I haven't been able to repeat this locally :( I'm guessing that you're running Guardian 0.6.1 which was a bit buggy. GuardianDb was requiring this version. I've updated GuardianDb to rely on 0.6.2 in v 0.1.2. Can you please update guardian db and guardian and see if you still have the same issue?

@yuyabee
Copy link
Contributor

yuyabee commented Sep 20, 2015

@hassox Yes that was it. Upgrading to 0.6.2 solved it. Thank you so much.

@hassox
Copy link
Member

hassox commented Sep 20, 2015

Phew! Thanks so much for looking into it :)

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

No branches or pull requests

3 participants