Skip to content

Conversation

@felixarntz
Copy link
Member

Fixes #143

@felixarntz felixarntz added this to the 0.4.0 milestone Dec 12, 2025
@felixarntz felixarntz added the [Feature] New feature to highlight in changelogs. label Dec 12, 2025
@github-actions
Copy link

github-actions bot commented Dec 12, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: felixarntz <[email protected]>
Co-authored-by: JasonTheAdams <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @felixarntz! A couple points I'm a bit confused on.

Comment on lines 85 to 87
if ($authenticationMethod === null && $type->isCloud()) {
$authenticationMethod = RequestAuthenticationMethod::apiKey();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we just considering this a safe assumption?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I added this for backward compatibility, but I already started thinking yesterday "what if there's a cloud provider that doesn't need any authentication and therefore wants this to be null?

Maybe we just get rid of it and always use null as a default? It's a BC break, but probably not that important given almost nobody is implementing providers.

return ApiKeyRequestAuthentication::class;
}

return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems logically impossible to arrive here? How is this method nullable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I suppose for now this can unconditionally return ApiKeyRequestAuthentication because that's the only value for the enum. I'll update this.

get_class($requestAuthentication)
)
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by this logic. We get the authentication method enum from the provider class, then we get the authentication class derived from the enum, null if the enum is null, and then we throw an exception if the authentication class is null saying that it does not expect authentication but has an authentication method enum.

The only way this would get here would be if the getImplementationClass() method returned null, but that's logically impossible (see my other comment).

I also notice this down below, too. I guess it all hinges on whether the getImplementationClass() return type is in fact nullable or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clause is there because one shouldn't attempt to set a RequestAuthentication instance for a provider that doesn't need any authentication (i.e. where authenticationMethod is null).

I agree with your feedback that the getImplementationClass() return type shouldn't be nullable, so I'll update, and then the logic here has to be adjusted accordingly. But at its core the condition will still be needed - it'll instead just check whether the authenticationMethod is null instead of whether the expectedClass is null. Makes sense?

@felixarntz
Copy link
Member Author

@JasonTheAdams I've updated the PR based on the comments feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] New feature to highlight in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add provider association with specific authentication method

3 participants