Authentication answers: "Who are you?"
Authorization answers: "Are you allowed to perform this action?"
Authentication may establish the current user through a session, token, or another mechanism.
Authorization can use gates or policies.
Example:
if ($user->can('update', $post)) {
// allow update
}
Scenario:
A support employee may be authenticated but still be forbidden from deleting financial records. Authentication identifies the employee; authorization determines whether deletion is permitted.
Interview tip:
Do not describe authentication and authorization as the same thing. This distinction is fundamental to secure application design.
0 comments:
Post a Comment
Thanks