I'm following this tutorial to set up Authentication https://book.cakephp.org/authentication/2/en/index.html with CakePHP4.
The table where my users are stored is not called "users" so when I try to log in it gives me this error:
Base table or view not found: 1146 Table 'databasename.users'
Where can I specify the userModel? In which file should it be set up? How?
You have to configure the respective resolver accordingly, in this case the ORM resolver.
Resolvers are used by identifiers, which accept resolver configuration via the resolver option. So for example for the password identifier, you could do it like this:
$service->loadIdentifier('Authentication.Password', [
'resolver' => [
'className' => 'Authentication.Orm',
'userModel' => 'YourCustomModelName',
],
// ....
]);
Note that it's necessary to pass the class name too when passing an array of resolver configuration, as the default configuration is just a string (the resolver class name), so it will not merge with the defaults, but overwrite them!
See also
Authentication Cookbook > Identifiers
Authentication Cookbook > Identifiers > Identity resolvers
Related
I've successfully cloudformed a cognito identity-pool and could not see how I add the custom mappings to the "Cognito" "Authentication Providers" in cloudformation.
Inside the Cognito Authentication Provider on the console, there is a dropdown where I manually have to select "Use custom mappings" and then I can manually add the mappings to my custom user attributes. However, I need to be able to cloudform this and am struggling to find the correct place for it.
The user pool that goes along with this identity pool has "SupportedIdentityProviders" set to "COGNITO"
Update
I can get a list of identity providers by running ...
aws cognito-identity list-identities --max-results 2 --identity-pool-id xx-xxxx-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
and this returns me
{
"IdentityPoolId": "xx-xxxx-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
"Identities": [
{
"IdentityId": "yy-yyyy-y:yyyyyyyy-yyyy-yyyy-yyyyyyyyyy",
"Logins": [
"cognito-idp.eu-west-2.amazonaws.com/eu-west-2_tFT6FBwIO"
],
"CreationDate": "2021-11-15T12:38:48.249000+00:00",
"LastModifiedDate": "2021-11-15T12:38:48.263000+00:00"
}
]
}
using the "Logins" information I can now run...
aws cognito-identity get-principal-tag-attribute-map --identity-pool-id xx-xxxx-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx --identity-provider-name "cognito-idp.eu-west-2.amazonaws.com/eu-west-2_tFT6FBwIO"
which returns
{
"IdentityPoolId": "xx-xxxx-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
"IdentityProviderName": "cognito-idp.eu-west-2.amazonaws.com/eu-west-2_tFT6FBwIO",
"UseDefaults": false,
"PrincipalTags": {
"attr_x": "custom:attr_x",
"attr_y": "custom:attr_y",
"attr_z": "custom:attr_z"
}
}
However, I still don't know how to setup this mapping via cloudformation...
Regards
Mark.
Setting PrincipalTag attribute mappings is not yet supported in CloudFormation but, according to the CloudFormation roadmap, will be supported soon.
In the meantime, you would have to create a CloudFormation Custom Resource or Resource Provider to achieve this.
I'm working on some changes to:
https://github.com/puppetlabs/puppetlabs-rabbitmq/
I haven't worked much with rspec or with puppet types / providers, so it's been slow going. Haven't had much input via their ticket system or in Github, so just wanted to get some advice in terms of the design changes.
Basically, the module doesn't currently support multiple bindings with the same source / destination / vhost combo, but different routing keys.
I had a (mostly) working fix that was backwards compatible involving making routing_key work as either a string or array (https://tickets.puppetlabs.com/browse/MODULES-3679)
However, this doesn't work too well, because the existing provider expects the resource to be unique, and seems to assume a predictable mapping between the title of the resource and the
I had thought about making the title and name attributes different from each other, or even completely abstracting the name / title from the attributes that must be unique:
rabbitmq_binding { 'exchange1#queue1#host3-1':
name => 'exchange1#queue1#host3',
destination_type => 'queue',
routing_key => 'routingkey1',
ensure => present,
}
rabbitmq_binding { 'exchange1#queue1#host3-2':
name => 'exchange1#queue1#host3',
destination_type => 'queue',
routing_key => 'routingkey2',
ensure => present,
}
The actual rabbitmqctl output that self.instances is collecting for each vhost (in an example where there are two routing keys for same source / dest / vhost combo (no vhost in this example) looks like:
foo.bar.exchange exchange axs.bar.baz.queue queue axs.bar.baz.key []
foo.bar.exchange exchange axs.bar.baz.queue queue axs.bar.baz.published.key []
I'd rather not try to encode the routing key in the title / name attribute of the resource, but is it possible to have routing_key also tied to the resource (presumably by updating the exists? method as well as self.instances)? What would be the best things to check in unit tests for this (I already have an acceptance test), and how can I modify lib/puppet/provider/rabbitmq_binding/rabbitmqadmin.rb to support this?
Or do I just need to encode the routing key in the name as well, which just seems really ugly, and would also make backwards compatibility more difficult?
rabbitmq_binding { 'exchange1#queue1#host3#routingkey':
or
rabbitmq_binding { 'exchange1#queue1#/#routingkey':
Based on this Can anyone explain Laravel 5.2 Multi Auth with example
i will like to implement custom authentication on my app for the admin and users section but the whole concept is confusing maybe it is new to me in laravel 5.2 (my version) but at this stage i can say if i am getting it right or wrong but this is the error that is displaying.
InvalidArgumentException in CreatesUserProviders.php line 40:
Authentication user provider [] is not defined.
so i have done what #imrealashu answered but still i have issues.
It means that you didn't pass the guard like this:
auth('admin')->user();
//or
Auth::guard('admin')->user();
Or when you call the middleware auth in your controller, you need to pass the guard:
$this->middleware('auth:admin');
This video explains it https://www.youtube.com/watch?v=Vxh2ikaydfo (In spanish but its understandable )
I got that error when I tried to change in auth.php:
'provider' => 'users'
to
'provider' => 'user'
because my database table was user, not users.
That's not necessary. I just had to add to the User Eloquent class:
protected $table = 'user';
I'm developing a Yii application which uses several modules including Rights module for access control. They all are residing in the same "modules" folder and configured in the same config/main.php file. And application has only one entry script.
However I noticed that Rights module uses a different app session while all other modules uses another app session. Because of this reason user session is not shared with Rights.
Has anyone encounter such issue with yii modules? please help. Thanks!
my config file:
'rights'=>array(
'debug' => true,
'superuserName' => 'Super Administrator', // Name of the role with super user privileges.
'authenticatedName' => 'Customer', // Name of the authenticated user role.
'userIdColumn' => 'id', // Name of the user id column in the database.
'userNameColumn' => 'username', // Name of the user name column in the database.
'enableBizRule' => true, // Whether to enable authorization item business rules.
'enableBizRuleData' => true, // Whether to enable data for business rules.
'displayDescription' => false, // Whether to use item description instead of name.
'flashSuccessKey' => 'success', // Key to use for setting success flash messages.
'flashErrorKey' => 'error', // Key to use for setting error flash messages.
//'baseUrl' =>'/rights', // Base URL for Rights. Change if module is nested.
//'layout' => 'rights.views.layouts.main', // Layout to use for displaying Rights.
//'appLayout' => 'application.views.layouts.main', // Application layout.
//'cssFile' => 'rights.css', // Style sheet file to use for Rights.
'install' => false, // Whether to enable installer.
),
After trying for two days I found the solution.
I noticed that it uses two different key prefixes (stateKeyPrefix) in system. One for Rights and another one for other modules. This can be configured to use single key prefix in main config file.
'user'=>array(
'class'=>'RWebUser',
'allowAutoLogin'=>true, // enable cookie-based authentication
'stateKeyPrefix'=>'f298d9729c7408c3d406db95a9639204', // some random value
),
Hope this will help someone with the same issue.
I know I am either skipping something or configured session incorrectly but Yii sessions are not working for me. I have spent a lot of time in debugging and searching but it doesn't result in any concrete answer.
As described in documentation as well as tutorials over internet I have configured my application session as follows:
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'session' => array (
'sessionName' => 'Site Session',
'class'=>'CHttpSession',
'useTransparentSessionID' =>($_POST['PHPSESSID']) ? true : false,
'autoStart' => 'true',
'cookieMode' => 'allow',
'timeout' => 300
),
However each time I am sending a request to server, I get a new session object. I have verified same via echo "Session id: ".Yii::app()->session->sessionID;, every time it gives me different id. Also variables which I have added in session previously are not accessible due to this behaviour.
Kindly provide some pointers, I have spent more than 4 hours in debugging and looking for a solution. Tons of thanks for any pointers in advance.
Thanks
~Tarun
It could well be just that you have a space in your sessions name.
I've just done a quick test on my working Yii instance, changed the session name to have a space in it, and the cookie value for the session seems to change every time.
Please read php session name documentation at this url http://php.net/manual/en/function.session-name.php
It clearly mentions that session name should contain only alphanumerical characters. That too it should contain at least one alphabet(session name cannot have all its characters as digits also). Otherwise a new session id is generated every time.
chrome 44 and chrome 47's bug , update it to 51,It's ok.
Just a note cause I ran into this issue in Yii2. I had a constant COOKIE_DOMAIN that was set via php-fpm config and it was for the wrong domain name, causing the session to reset. Make sure this is set to ".example.com" (including the . at the start to support all your hostnames)
'components'=>[
'session' => [
'class' => 'yii\web\DbSession',
'cookieParams' => [
'path' => '/',
'domain' => COOKIE_DOMAIN, // <<<--- check this
'secure' => true,
],
'writeCallback' => function($session){
return [
'user_id' => Yii::$app->user->id
];
},
'sessionTable' => 'session', // session table name. Defaults to 'session'.
],
...
]