-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow extra fields to Authorization/Authentication Success #29
Allow extra fields to Authorization/Authentication Success #29
Conversation
Hello, thanks for reaching out and taking the time to build a PR. I am afraid however that I will not be merging this PR for it's moving the library into several undesirable directions. In particular, the use of the In addition, there are actually some subtle differences between grants which are hard to capture under one abstraction. Once again, I've preferred for the sake of the developer experience to keep each module only about one grant to reduce the amount of noise and, provide better on-the-spot names and types. About the issue itself, I am not quite positive about extending the parsers in such ways, because it creates noise for those who won't be needing those features. The library / specification in itself is already quite a big piece to consume, so I'd like to keep the entry barrier as low as possible by providing ready-to-use constructors for the common cases. Now, you're right when saying that the amount of tweaking / customization currently available isn't sufficient to do what you want to do (which seems very reasonable!). I've thereby worked out another PR which should address all of your points and also points mentioned by some other users on #21 and #23, but preserving a bit more the original intent of the library w.r.t the developer experience. Please, have a look at #30 and in particular, the diff highlighted in the PR description and let me know if it indeed solves your problem nicely. Finally, if the OAuth2.0 provider you're integrating against is publicly available, I'd be very much interested in adding it to the examples to show how to use these custom / advanced constructors. |
Hi. I understand, and I agree with your reasons. In fact, I was pretty sure the duplication was intended, and I shouldn't have included my "refactoring" if I wanted to pitch my proposal anyway. Also, I agree with the fact that my approach was introducing too much noise for consumers of the library that follow the OAuth spec to the letter, your solution looks better. In fact, I tried it locally, making some changes to my app to use the new API, it was pretty quick, and it works fine. For the last question, the OAuth provider was created using the Doorkeeper gem for Rails, it is different because it includes a Thanks for the new PR, it solved my issue.. |
Thanks for link. Seems like that is what powers https://oauth.io so I'll see if there's maybe a way to do an integration with that as an example. Hopefully, this non-standard
Great! I will close this PR then, merge the other one and prepare a release. |
See elm-oauth2@8.0.0. |
Why?
The OAuth Server used by me, and many others, provide more than just the Default Fields mentioned in the OAuth2 spec. This library mentions that you can somehow provide your own decoders (
Json decoder for a positive response. You may provide a custom response decoder using other decoders from this module, or some of your own craft.
) but I did not see how, and even so, the end result is still anAuthenticationSuccess
or anAuthorizationSuccess
based on the flow, and these fields cannot be changed, nor can I expect a different return type. The goal of this PR is to make these two types into Extensible Types, with a spot for placing your own Extra Fields type if you need it, and a way to pass your own decoders for those extra fields.What changed?
AuthenticationSuccess and AuthorizationSuccess are now two extensible types
BEFORE:
type alias AuthenticationSuccess = { ... }
AFTER:
type AuthenticationSuccess extraFields = AuthenticationSuccess { ... } extraFields
Same for
AuthorizationSuccess
Added a customAuthenticationSuccessDecoder
Added a customAuthorizationSuccessParser
Moved duplicated JSON decoders into the OAuth.elm file (I did not understand why they were duplicated)
All other changes were mainly my way of fixing the errors I faced due to the constraints of the extensible types, and the removal of the duplicated decoders. I tried to preserve the original API as much as possible, but this is still a major change. Let me know if you like this idea, and you would like to change anything here, there is still room for improvements, and cleanup, but for now I would like to know your opinion on this idea.