-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: Apply config settings #170
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant OAuthController
participant ConfigManager
User->>OAuthController: Request OAuth Login
OAuthController->>ConfigManager: Call setting('ShieldOAuthConfig.oauthConfigs')
ConfigManager-->>OAuthController: Return OAuth Config
OAuthController->>User: Redirect to OAuth Provider
sequenceDiagram
participant User
participant OAuthController
participant ConfigManager
User->>OAuthController: OAuth Callback
OAuthController->>ConfigManager: Call setting('ShieldOAuthConfig.registrationAllowed')
ConfigManager-->>OAuthController: Return Registration Status
alt Registration Allowed
OAuthController->>User: Register User
else Registration Not Allowed
OAuthController->>User: Show Error
end
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Controllers/OAuthController.php (3 hunks)
Additional context used
GitHub Check: PHP 8.1 Static Analysis
src/Controllers/OAuthController.php
[failure] 35-35:
Function setting not found.
[failure] 96-96:
Function setting not found.
[failure] 167-167:
Function setting not found.
GitHub Check: PHP 8.0 Static Analysis
src/Controllers/OAuthController.php
[failure] 35-35:
Function setting not found.
[failure] 96-96:
Function setting not found.
[failure] 167-167:
Function setting not found.
GitHub Check: PHP 7.4 Static Analysis
src/Controllers/OAuthController.php
[failure] 35-35:
Function setting not found.
[failure] 96-96:
Function setting not found.
[failure] 167-167:
Function setting not found.
Additional comments not posted (3)
src/Controllers/OAuthController.php (3)
35-35
: Approve the change, but verify thesetting
function.The change aligns with the PR objective of enabling overriding OAuth configuration settings from the application settings.
However, static analysis tools report that the
setting
function is not found. Please ensure that thesetting
function is defined and works as expected.Tools
GitHub Check: PHP 8.1 Static Analysis
[failure] 35-35:
Function setting not found.GitHub Check: PHP 8.0 Static Analysis
[failure] 35-35:
Function setting not found.GitHub Check: PHP 7.4 Static Analysis
[failure] 35-35:
Function setting not found.
96-96
: Approve the change, but verify thesetting
function.The change aligns with the PR objective of enabling overriding OAuth configuration settings from the application settings.
However, static analysis tools report that the
setting
function is not found. Please ensure that thesetting
function is defined and works as expected.Tools
GitHub Check: PHP 8.1 Static Analysis
[failure] 96-96:
Function setting not found.GitHub Check: PHP 8.0 Static Analysis
[failure] 96-96:
Function setting not found.GitHub Check: PHP 7.4 Static Analysis
[failure] 96-96:
Function setting not found.
167-167
: Approve the change, but verify thesetting
function.The change aligns with the PR objective of enabling overriding OAuth configuration settings from the application settings.
However, static analysis tools report that the
setting
function is not found. Please ensure that thesetting
function is defined and works as expected.Tools
GitHub Check: PHP 8.1 Static Analysis
[failure] 167-167:
Function setting not found.GitHub Check: PHP 8.0 Static Analysis
[failure] 167-167:
Function setting not found.GitHub Check: PHP 7.4 Static Analysis
[failure] 167-167:
Function setting not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- composer.json (1 hunks)
Additional comments not posted (1)
composer.json (1)
29-29
: LGTM!The addition of the
codeigniter4/settings
dependency with version constraint^2.2
is approved. This change aligns with the PR objective of enabling the overriding of OAuth configuration settings directly from the application settings.
composer.json
Outdated
@@ -25,7 +25,8 @@ | |||
"require": { | |||
"php": "^7.4.3 || ^8.0 || ^8.1 || ^8.2", | |||
"ext-curl": "*", | |||
"codeigniter4/shield": "^1.0" | |||
"codeigniter4/shield": "^1.0", | |||
"codeigniter4/settings": "^2.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d like to clarify that the Setting package is required for Shield to function properly, and in turn, Shield is essential for Shield OAuth. Therefore, it seems there’s no need for Setting package at this point, as the necessary dependencies are already in place.
"codeigniter4/settings": "^2.2" |
src/Controllers/OAuthController.php
Outdated
@@ -32,7 +32,8 @@ public function redirectOAuth(string $oauthName): RedirectResponse | |||
return redirect()->to(config('Auth')->loginRedirect()); | |||
} | |||
|
|||
if (config('ShieldOAuthConfig')->oauthConfigs[$oauthName]['allow_login'] === false) { | |||
/** @phpstan-ignore-next-line */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using /** @phpstan-ignore-next-line */ to suppress the error, you can fix it by making the following change:
scanDirectories:
- vendor/codeigniter4/settings/src/Helpers
This will allow PHPStan to properly scan the necessary directories and resolve the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your guidance. I have sent an update. please review it.
LGTM! Thanks! |
Because the login and registration routes are combined into one link, this makes it difficult to differentiate between OAuth login and OAuth registration. This can cause confusion.
for example: when a user intends to log in but instead gets registered, even though they don't want to register their email. Therefore, it needs to be prevented by using proper settings and its implementation must be placed inside the controller.
This PR allowed to override the oauth config from the settings.
Example:
Summary by CodeRabbit
New Features
Bug Fixes
Chores
codeigniter4/settings
for better configuration management.