Comments (14)
- Remove Authentication middleware from the route.
- Use
$currentUser->isGuest()
in your controller.
from auth.
@rustamwin If remove Authentication middleware in route, $currentUser->isGuest() alway return true.
from auth.
@hiscaler You should add optional routes to withOptionalPatterns()
method. For example:
Authentication::class => [
'class' => Authentication::class,
'__construct()' => [
'authenticationFailureHandler' => Reference::to(PassportRequestErrorHandler::class),
],
'withOptionalPatterns()' => [
'optional' => [
'/en/products/[1-9]',
'products/product/view', // Don't forget adapt pattern for your case
]
]
],
from auth.
@vjik I will try. Thank you!
from auth.
@vjik Can not.
GET /en/products/1 is return product 1 detail
PUT /en/products/1 is update product 1 detail
DELETE /en/products/1 is delete product 1
but withOptionalPatterns.optional
['/en/products/[1-9]']
can't not know what's request method.
from auth.
and has a other question.
['/en/products/[1-9]{1}']
can't matched /en/products/123
from auth.
@hiscaler see patterns https://github.com/yiisoft/strings/blob/master/README.md#wildcardpattern-usage
from auth.
@rustamwin Thank you!
from auth.
@hiscaler see patterns https://github.com/yiisoft/strings/blob/master/README.md#wildcardpattern-usage
Valid setting is ['/en/products/[1-9]*'] , thank you.
from auth.
@vjik Can not.
GET /en/products/1 is return product 1 detail PUT /en/products/1 is update product 1 detail DELETE /en/products/1 is delete product 1
but withOptionalPatterns.optional
['/en/products/[1-9]']
can't not know what's request method.
So i think should add check request method in Authentication.isOptional
from auth.
@hiscaler you want make optional authentication for GET request only and otherwise required (POST, DELETE, etc.)?
from auth.
@vjik yes, is only GET request, POST, DELETE is must authentication
from auth.
Need add ability to specify request type in optional patterns.
from auth.
Another idea: leave in Authentication
middleware authentication process only and create new middleawre that will be throw exception or return response "No access".
from auth.
Related Issues (8)
- Separate identity repository for token
- IdentityWithTokenRepositoryInterface should not extend IdentityRepositoryInterface
- Re-introduce authKey
- Add interface for Token invalidation HOT 1
- Add check to non-empty pattern in `HttpHeader::withPattern()` method HOT 2
- Add support of `psr/http-message` version 2.0 HOT 1
- Remove scrutinizer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auth.