WP-API / OAuth2

Connect applications to your WordPress site without ever giving away your password.
GNU General Public License v2.0
172 stars 42 forks source link

House cleaning. #8

Closed tfrommen closed 7 years ago

tfrommen commented 7 years ago

Hi there! πŸ‘‹

I had some time, so I went through the current code base (i.e., the auth-code-flow branch, which this PR thus targets), with an army of house elves, and fixed, updated and improved a few things here and there.

Sorry for not splitting up commits. I did this on purpose, though, because otherwise we would've ended up with 42 (!) commits, ... or so. I did not do any real changes to functionality, though, but see for yourself...

What Does This Pull Request Include?

What's Left?

Again, this PR targets the auth-code-flow branch. If you want me to make it target master instead, just tell me.

Cheers, Thorsten

rmccue commented 7 years ago

Sorry for missing your other questions here!

Every third file looks different than the others.

Yeah: half of this code comes from the original OAuth 1 project and follows that code style, half of it is new and follows the HM coding standards (essentially, modernised WP standards).

Where to put blank lines (both in code and comments)?

Same as WP generally; generally a blank line before a comment line.

Import classes in the global namespace, yes or no?

Yes: all classes that aren't in the current namespace should be imported.

admin.php:

Kept this around for #13, will eventually go πŸ’€

inc/class-scopes.php:

Not used yet, see #10. The code there is just the skeleton that I created in a rush to get my thoughts down.

the OAuth2\get_grant_types() function should both validate the data (and remove invalid handlers) and state WP\OAuth2\Types\Type[] instead of array as return type

Makes sense to me; will merge #14 in a moment. :)

I assume the $args parameter in WP\OAuth2\Tokens\Authorization_Code::validate() is for inheritance...?

Currently unused, but we need to validate a few things to be spec compliant, notably redirect_uri. Haven't written that code yet. :)

tfrommen commented 7 years ago

Sorry, too, because not all of the things in What's Left were real questions, or at least not questions to get answered (just thought about and eventually resolved).

The coding style parts were just to enumerate what I encountered (inconsistent blank lines, inconsistent namespace imports, etc.).

I just updated #14, although you still have to decide about the intended behavior when encountering an invalid type.

Just to have said that: for me, this PR is done (merged anyway, and all questions answered). Thanks. πŸ™‚