4d / 4D-NetKit

4D NetKit is a built-in 4D component that allows you to interact with third-party web services and their APIs.
Other
10 stars 8 forks source link

Big refactoring to allow more generic providers. #3

Closed Ganbin closed 1 year ago

Ganbin commented 2 years ago

Hi,

I haves spend some time to adapt the code to allow a more generic approach to extend to more specific implementation of OAuth2.

The OAut2 specs are a base where providers can require more customised parameters in the workflow.

I have created a OAuth2BaseProvider that return only the official OAuth2 setting needed or optional.

I have made 2 extended classes :

Both extended classes use a hook called authenticateURIExtender that allow to execute some code on the url before the authorization call is send.

The extended classes can also override the checkPrerequisites function to allow to have more specific prerequisites.

I think this approach can allow in the future to add some hooks in the workflow if a specific implementation is needed without broking existing code. We simply need to have the base class to implement a hook function that do "nothing" and the extended class that implement so specific code.

The provider classes have to be given to the OAuth2 class that will then be able to getToken.

This is a proposition and maybe the code cannot be integrated directly.

mesopelagique commented 1 year ago

sorry to have closed your PR Because I remove the unused branch master on where the PR is based, it automatically close it

A new main branch will come instead of master, and PR will be more studied because we will work on github (and github will not be only a mirror of our internal VCS)

Ganbin commented 1 year ago

Ok thanks for the info. It would be great to see more activity of 4D directly on Github!