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

Support other authentication backends #20

Closed
aleffert opened this issue Jan 12, 2019 · 7 comments
Closed

Support other authentication backends #20

aleffert opened this issue Jan 12, 2019 · 7 comments

Comments

@aleffert
Copy link
Contributor

I'd like to use https://github.com/James1345/django-rest-knox instead of the built in TokenAuthentication backend. I'm fine using the existing system for the initial 6-digit codes, this change would only be for the final token generated after a successful callback.

I have an idea about what this PR would look like and I think it's pretty small, but wanted to talk it out before spending time on implementation.

In particular, it looks like https://github.com/aaronn/django-rest-framework-passwordless/blob/master/drfpasswordless/views.py#L131 is the only place a 6-digit code gets turned into a token, so I'd like to abstract that out.

This would entail:

  1. Adding a new setting PASSWORDLESS_AUTH_TOKEN_CREATOR which is a string that will get mapped to a string by the settings infrastructure. This function would take a user and return (string, bool) matching the existing call. This would default to a function containing the current code.

  2. Update the call linked above to invoke whatever function is bound to PASSWORDLESS_AUTH_TOKEN_CREATOR .

Does this sound good?

Thanks for a great project!

@aaronn
Copy link
Owner

aaronn commented Feb 27, 2019

Yeah, I'm actually interested in using Knox myself– so I would be down for a PR that implements a way to swap that out.

I don't understand your implementation though– in 1. did you mean a string that will get mapped to a function? Which existing call returns (string, bool)? Basically though I'm fine with what you're proposing as long as it still works with DRF tokens default out of the box (which it sounds like it will).

@aleffert
Copy link
Contributor Author

yeah, I meant the string will get mapped to a function. I'll try to whip up a PR in the next few days

@bwesen
Copy link
Contributor

bwesen commented Mar 15, 2019

We're interested in the same, but we need it to add a refresh token in between. The only Django module I could find that does this is the Oauth Toolkit, so I guess I need a way to get drfpasswordless to ask oauth toolkit for a token (instead of the built-in Token directly). So, same issue, other use-case :) Would be cool if we can support a generic mechanism.

@charleshan
Copy link
Contributor

Any updates for this? Looks like @aleffert made a pull request (#21) but never got merged.

@aaronn
Copy link
Owner

aaronn commented Jan 22, 2020

Should be in 1.3.9+

@aaronn aaronn closed this as completed Jan 22, 2020
@Terkea
Copy link

Terkea commented Apr 15, 2020

Could anyone provide an example where using Knox Tokens?

@eluce2
Copy link

eluce2 commented Dec 30, 2020

@aaronn I'm trying to integrate this with Knox, but after implementing my custom create_authentication_token method that generated the knox token, I get an error in the view:

AttributeError: 'str' object has no attribute '__dict__'

Would you mind sharing how you were able to implement this with Knox? What is it that Knox needs to create for this to work?

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

6 participants