Mailing List Archive

catalyst authorization , self_check
Hi ,

the roles of my users cannot be represented in a table column
for a separate relation . It involves some logic that can be put
in a subroutine/method of my DBIx::Class schema object
representing the user.


my Auth setup is as below:


=====================================================
__PACKAGE__->config->{'Plugin::Authentication'} =
{
default => {
class => 'SimpleDB',
user_model => 'DB::MyProjectUser',
password_type => 'self_check',
}
} ;
=====================================================

i have implemented the 'check_password' in MyProjectUser.pm
and it works well. What i need is similar flexibility to specify the
roles of an existing user . I cannot use role_field , role_relation



Regds

Rajesh Kumar Mallah.
Redgrape Technologies ( https://www.redgrape.tech )
Mobile: 09811255597, Land: 011-49044122
----------------------------------------------------------------------------------------------------------

Opportunities are usually disguised as hard work, so most people don't
recognize them
----------------------------------------------------------------------------------------------------------
Re: catalyst authorization , self_check [ In reply to ]
On 13 November 2017 at 15:21, Rajesh Mallah <mallah@redgrape.tech> wrote:
> Hi ,
>
> the roles of my users cannot be represented in a table column
> for a separate relation . It involves some logic that can be put
> in a subroutine/method of my DBIx::Class schema object
> representing the user.
[...]
> i have implemented the 'check_password' in MyProjectUser.pm
> and it works well. What i need is similar flexibility to specify the
> roles of an existing user . I cannot use role_field , role_relation

Just use role_column!

Giving the name of your subroutine/method as role_column, and making
sure it returns a suitable space- or comma-separated list of role
names, should be sufficient (a quick check of the code in
Catalyst::Authentication::Store::DBIx::Class::User shows it just calls
the method if it exists, it doesn't actually need to be a column
accessor).

Waiting to be proven wrong if there's code anywhere else checking that
it's actually a column ... :o)

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: catalyst authorization , self_check [ In reply to ]
Thanks it did work!

and Thanks again for replying so soon!

Kind Regards
Rajesh Mallah.

============================

lib/MyProj/Schema/Result/MyProjUser.pm

sub myrolecol {

my ($self) = @_;

my $log = Log::Log4perl->get_logger();
$log -> debug ("myrolecol has been called!");
return "thisrole|testrole";

}

============================================

__PACKAGE__->config->{'Plugin::Authentication'} =
{
default => {
class => 'SimpleDB',
user_model => 'DB::MyProjectUser',
password_type => 'self_check',
role_column => 'myrolecol'
}
} ;

===========================================

the reason i was not able to get it was , I was using 'role_field'
instead of 'role_column'

Regds

Rajesh Kumar Mallah.
Redgrape Technologies ( https://www.redgrape.tech )
Mobile: 09811255597, Land: 011-49044122
----------------------------------------------------------------------------------------------------------

Opportunities are usually disguised as hard work, so most people don't
recognize them
----------------------------------------------------------------------------------------------------------


| From: "Will Crawford" <billcrawford1970@gmail.com>
| To: "Catalyst" <catalyst@lists.scsys.co.uk>
| Sent: Monday, November 13, 2017 9:25:58 PM
| Subject: Re: [Catalyst] catalyst authorization , self_check

| On 13 November 2017 at 15:21, Rajesh Mallah <mallah@redgrape.tech> wrote:
|> Hi ,
|>
|> the roles of my users cannot be represented in a table column
|> for a separate relation . It involves some logic that can be put
|> in a subroutine/method of my DBIx::Class schema object
|> representing the user.

| [...]
|> i have implemented the 'check_password' in MyProjectUser.pm
|> and it works well. What i need is similar flexibility to specify the
|> roles of an existing user . I cannot use role_field , role_relation

| Just use role_column!

| Giving the name of your subroutine/method as role_column, and making
| sure it returns a suitable space- or comma-separated list of role
| names, should be sufficient (a quick check of the code in
| Catalyst::Authentication::Store::DBIx::Class::User shows it just calls
| the method if it exists, it doesn't actually need to be a column
| accessor).

| Waiting to be proven wrong if there's code anywhere else checking that
| it's actually a column ... :o)

| _______________________________________________
| List: Catalyst@lists.scsys.co.uk
| Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
| Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
| Dev site: http://dev.catalyst.perl.org/