Re: [Catalyst] Catalyst with HTTP authentication

2013-03-11 Thread Tim Anderson
Ditto.  I am also using Catalyst::Authentication::Credential::Remote, and
it is working just fine.


-Tim


On Mon, Mar 11, 2013 at 9:37 AM, Lukas Thiemeier
wrote:

> >From reading the docs, I don't see why
> Catalyst::Authentication::Store::Htpasswd and
> Catalyst::Authentication::Credential::HTTP do not work together, but I
> have not used any of them.
>
> I am using Catalyst::Authentication::Credential::Remote in a current
> project. It lets the webserver do all the authentication. You can use
> any authentication method and storage which is supported by your
> webserver, including htpasswd files.
>
> I am using Catalyst::Authentication::Credential::Testing for
> authentication when the webserver is not available (when running the
> catalyst test-server during development).
>
> Maybe this is an option for you...
>
> cheers, Lukas
>
> On 03/11/2013 03:10 PM, Robert Rothenberg wrote:
> > I have a project that requires using HTTP authentication.
> >
> > There is a Catalyst::Authentication::Credential::HTTP module, but from
> the
> > documentation, it does not seem to support using htpasswd files, which I
> > need, because a separate web site will be using that file.
> >
> > There is Catalyst::Authentication::Store::Htpasswd, but it does not work
> > with Catalyst::Authentication::Credential::HTTP.
> >
> > I'm not clear on how to do this, without having to write my own handlers
> for
> > HTTP authentication.
> >
> >
> > ___
> > 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/
>
>
> ___
> 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/
>
___
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] Catalyst with Twiggy with Pocket.IO (Comet)

2012-11-28 Thread Tim Anderson
I also faced this problem, and what I did to resolve it was move the
authentication piece out to Apache (from my Catalyst application), and then
used the Catalyst::Authentication::Credential::Remote module to 'use' what
Apache is doing for me.  Once the auth config is in Apache, you can use it
to authenticate other applications as well (in my case it was a series of
Tomcat servlets).  I'm really pleased with the solution.


-Tim


On Wed, Nov 28, 2012 at 9:04 AM, Gabriel Andrade  wrote:

>
> On Nov 28, 2012, at 9:21 AM, Jaro Zajonc  wrote:
>
> > But if I direct traffic from Apache directly to Twiggy server I'd bypass
> Catalyst Authentication/Authorization part for Comet session, right?
> > I'd like to allow only authenticated users to subscribe to comet channel.
> > I am sure I am missing some really simple piece of the puzzle :-\
>
>
> I've been through the same dilemma. Solved it by sharing appropriate
> data between Plack and Catalyst using
> Catalyst::TraitFor::Request::Plack::Session.
> It's clumsy and I haven't thoroughly tested it, though… So, there might be
> (serious)
> limitations.
>
> Here's how it goes…  something along these lines:
>
> builder {
>   enable 'Session',
> store =>
> Plack::Session::Store::Cache->new( cache => CHI->new( driver => (…) )
> );
>
>   mount '/' => $catalyst_psgi_app;# auth, etc..
>   # (you're logging in first, aren't
> you?)
>
>   # when you reach here, auth is already made
>   # and Plack::Session is stuffed
>
>   mount '/socket.io' => PocketIO->new(
> handler => sub {
>   $_[1]->{'psgix.session'}->{can_foo};
> }
>   );
> };
>
> … and then
>
> > plackup -s AnyEvent::FCGI myapp.psgi
>
> Also, here, a message queue suits it well for sharing data and
> messaging passing, given you've already pointed the proper queue key
> in session.
> ___
> 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/
>
___
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] Catalyst and Java

2012-10-31 Thread Tim Anderson
Thank you both for your suggestions.  Creating my own model is along the
lines of what I was thinking, but I know in advance that this is going to
really stretch my abilities.

Another possibility that has occurred to me since my original post is that
I could remove the authentication to Apache (using
Catalyst::Authentication::Credential::Remote).  If the authentication is at
that level, I know I can get it to protect both resources and provide a
seamless experience to the user.

Somehow, though, creating my own model seems like the more appealing
option



-Tim


On Wed, Oct 31, 2012 at 12:22 PM, Ashley Pond V  wrote:

> On Wed, Oct 31, 2012 at 8:41 AM, Devin Austin 
> wrote:
> > On Wed, Oct 31, 2012 at 3:50 AM, Tim Anderson  wrote:
> >>
> >> I have a handful of java servlets that I would like to 'front-end' with
> my
> >> Catalyst application, essentially using Catalyst to provide
> >> authentication/authorization before passing along the browser requests
> to
> >> the servlet.
>
> >> Does anyone have experience with doing something like this?  I'd
> appreciate
> >> any insight or direction.
> >
> > This would be fairly do-able if you used REST for inter-app
> > communication.  Or something like Message::Passing, which allows you
> > to send a "message" to a queue, which could be subscribed to from both
> > ends, thus allowing the apps to talk to each other.
> >
> > If the Catalyst app is acting as a proxy to the servlets, I would
> > think you could do a pretty regular
> > authentication/authorization/session set up with it and just pass
> > along whatever other info you need to the servlets via the
> > aforementioned means.
>
> Another approach worth considering is to wrap the servlets up in a
> model. This often takes a bit longer and more thinking in the set-up
> phase but will give you code that is easier to reuse in other places.
> I've done this kind of problem both ways and either is fine but I'd
> lean to the model. You would end up with something you could run with
>
> Catalyst/Flea/Mojolicious/in-line-plack-with-auth-middleware/command-line/whatever.
>
> ___
> 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/
>
___
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/


[Catalyst] Catalyst and Java

2012-10-31 Thread Tim Anderson
I have a handful of java servlets that I would like to 'front-end' with my
Catalyst application, essentially using Catalyst to provide
authentication/authorization before passing along the browser requests to
the servlet.  I don't need session information in the servlet, and I'm
willing to leave the servlet unsecured on an obscure port (network
protected, of course) in order to allow Catalyst to more easily interact
with it. In my mind, I see Catalyst behaving as a proxy, managing the
entire conversation, but I'd also be open to some kind of redirection
solution.

Does anyone have experience with doing something like this?  I'd appreciate
any insight or direction.


-Tim
___
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] I'm loosing the plot here? - Controller behaviour that makes no sense

2012-10-30 Thread Tim Anderson
Craig,

Might I suggest following Lukas' advice from yesterday and working through
the tutorial before building your own site.  Catalyst is a great framework
but it's not trivial, and I had several of the same kinds of questions when
I first started out.

I clued in on your 'when neither output should show' statement; what are
you expecting from 'mydomain:port/login' in your example.  It looks to me
like /login should be matching your Login controller, and because you
haven't specified a further path, your output is going to be 'this sucks',
from the index function.

-Tim


___
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] The Definitive Guide to Catalyst ... p. 165 listing all users and their roles

2012-07-11 Thread Tim Anderson
Sorry Robyn (and others I may have misled), I'm wrong.

I reviewed again, and you're not leveraging the many_to_many at all.
 You're following a path that looks like this:

[% FOREACH role = user.user_roles %]

User.pm has a 'has_many' relationship called 'user_roles' that you are
leveraging, in each iteration of this loop role is set to a a UserRole row
object.


   [% role.role.role %]

UserRole row object has 'belongs_to' relationship called 'role' (the second
'role' in the TT string above.  This is why fREW's answer works.
 Originally, using role_id accessed the value of role_id column in the
UserRole row, but you need to go one level deeper, so you use the
belongs_to 'role' to step to the related Role object row.
The related Role object has a value of role (the third 'role' in the TT
string), and this is the value that you want printed out.


[% END %]

I hope this helps.  I'm learning too.  I've taken a lot from this list, and
I'm trying to give back.


-Tim


On Wed, Jul 11, 2012 at 1:25 PM, Robyn Jonahs wrote:

> Thanks Tim,
>
> I thought that the many_to_many was a relationship bridge and as limited
> to what it could do. I was studying the many_to_Many examples in the book
> to help my real problem in a test application I am trying to work on. I
> guess I should start a new thread for questions related to that. I will do
> that and try to continue understanding the relationships.
>
> Thanks
> RJ
>
> On Wed, Jul 11, 2012 at 12:48 PM, Tim Anderson  wrote:
>
>>
>> [% role.role.role %]  works because you're accessing the role
>> name (the third 'role') through the 'role' accessor (the second 'role')
>> which is defined in your many-to-many relationship:
>>
>> __PACKAGE__->many_to_many("roles", "user_roles", *"role"*);
>>
>> This is one of the beauties of DBIC; as soon as you have your
>> relationships defined, you have paths to the data you need.  Imagine trying
>> to write the same type of request across a multiple key relationship.
>>
>>
>> -Tim
>>
>>
>> On Wed, Jul 11, 2012 at 11:29 AM, Robyn Jonahs 
>> wrote:
>>
>>> Thanks, that worked. Now I am off to see why.
>>>
>>> [ snip ]
>>>
>>
>> ___
>> 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/
>>
>>
>
> ___
> 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/
>
>
___
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] The Definitive Guide to Catalyst ... p. 165 listing all users and their roles

2012-07-11 Thread Tim Anderson
[% role.role.role %]  works because you're accessing the role name
(the third 'role') through the 'role' accessor (the second 'role') which is
defined in your many-to-many relationship:

__PACKAGE__->many_to_many("roles", "user_roles", *"role"*);

This is one of the beauties of DBIC; as soon as you have your relationships
defined, you have paths to the data you need.  Imagine trying to write the
same type of request across a multiple key relationship.


-Tim


On Wed, Jul 11, 2012 at 11:29 AM, Robyn Jonahs wrote:

> Thanks, that worked. Now I am off to see why.
>
> [ snip ]
>
___
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] Using Progressive realms when username and password fields are all different

2012-06-28 Thread Tim Anderson
That keys in the hash reference you are passing to the authenticate
function should match the keys in your CcAgent model, plus the password
field you defined in your config... something like this:

# Attempt to log the user in

   if (
   $c->authenticate(
   {
   login => $username,
   passwd => $password
   },
   'progressive_oauth'
   )
 )
   {

-Tim


...snip...
___
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] Using Progressive realms when username and password fields are all different

2012-06-28 Thread Tim Anderson
Gavin,

Assuming you are using the Authentication plugin, you can define multiple
realm objects, each of which allows you to specify the columns to be used
for username and password.  The documentation is pretty good on this one,
and it's working well for me.

http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10020/lib/Catalyst/Plugin/Authentication.pm#CONFIGURATION


Does that help?

-Tim


On Thu, Jun 28, 2012 at 3:09 PM, Gavin Henry  wrote:

> Hi all,
>
> I have three realms; customers, resellers and admins. Each auth table
> in these realms is not consistent and uses different username_filed
> and password_field names. I can't change this.
>
> Now the normal way is to do:
>
> if (
> $c->authenticate(
> {
> username => $username,
> password => $password
> },
> 'progressive_test'
> )
>   )
>  {
>
> This fails as no realms have username and password as the actual
> column names. I wanted DWIM here so when I pass in username the auth
> framework actually uses what I've set in my config using
> username_field and password_field like so:
>
>
>
>class Password
>password_type clear
>username_field useralias
>password_field uipass
>
>
>class DBIx::Class
>user_model CustomerDB::Account
>
>
>
> Ideas?
>
> --
> http://www.suretecsystems.com/services/openldap/
> http://www.surevoip.co.uk/api
>
> ___
> 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/
>
___
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] create_related is failing on second time through loop?

2012-06-19 Thread Tim Anderson
Thanks for your response Robert.

The value when it crashes is valid.  In the case of the example I posted,
two roles were being inserted: 1 and 20.  This is the log text:

[debug] Creating new role: $VAR1 = '1';
[debug] Creating new role: $VAR1 = '20';


The '1' record made it into the database, and the failure came on '20'.  I
can successfully add '20' by itself, so I know it's not a referential
integrity issue (or some such thing).

-Tim


On Tue, Jun 19, 2012 at 1:22 PM, Robert Wohlfarth wrote:
>
>
> I see that you send $new_role to the log. What is the value when it
> crashes? An invalid value may cause unhelpful errors.
>
> --
> Robert Wohlfarth
>
>
___
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/


[Catalyst] create_related is failing on second time through loop?

2012-06-19 Thread Tim Anderson
Greetings,

I've been working with Catalyst for about 2 months, and up until yesterday
I was feeling pretty good about my proficiency... long way to go, though.
 I have been doing my development in a VirtualBox VM on my workstation and
arrived at a point where I wanted to move my application to it's new home.
 I set up the new server, installed the necessary Perl modules via CPAN,
and copied over my application.  Most of it works.

I have two tables, one with a has_many relationship to the other. My
application needs to take some posted data, updates a single record in the
main table, and then deletes and re-adds a variable number of records for
the 'has many' table.  When the variable number <= 1, all is well, but if
the number is >1, I get the following in my server output:

[error] DBIx::Class::Relationship::Base::create_related(): Unknown error:
execute() returned false, but error flags were not set... at
/opt/lms/catalyst/Portal/script/../lib/Portal/Controller/Users.pm line 429


The code in question:

   #handle user_roles
   my $roles = $c->request->params->{'user_role'};  #this is what is desired
   $roles = [ $roles ] if ref ($roles) ne 'ARRAY';

  my $existing_record = $c->model('DB::' .
$package_name)->has_record(\%form_key_vals);

   if (defined ($existing_record)) {

 $existing_record = $existing_record->update(\%form_vals);  #this is
working

 # Delete user's existing roles, then add the new ones
 $c->model('DB::PortalUserRole')->search({ client_id =>
$form_vals{client_id},
   user_id =>
$form_vals{user_id}, })->delete;  #this is working

 foreach my $new_role (@{$roles}) {
   $c->log->debug("Creating new role: " . Dumper($new_role));

   $existing_record->create_related ('portal_user_roles', { role_id =>
$new_role });  #first time through works, but fails on second pass
 }

   }

When I set DBIC_TRACE=1, I see the following stack trace:


DBIx::Class::Schema::throw_exception('Portal::Schema=HASH(0x35fd380)',
'Unknown error: execute() returned false, but error flags were...') called
at /usr/local/share/perl5/DBIx/Class/Storage.pm line 111

DBIx::Class::Storage::throw_exception('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'Unknown error: execute() returned false, but error flags were...') called
at /usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 1594

DBIx::Class::Storage::DBI::_dbh_execute('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'DBI::db=HASH(0x51679a0)', 'INSERT INTO PORTAL_USER_ROLE ( client_id,
role_id, user_id) V...', 'ARRAY(0x4fa0490)', 'ARRAY(0x533ea30)') called at
/usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 789
DBIx::Class::Storage::DBI::__ANON__() called at
/usr/local/share/perl5/Try/Tiny.pm line 71
eval {...} called at /usr/local/share/perl5/Try/Tiny.pm line 67
Try::Tiny::try('CODE(0x533e880)',
'Try::Tiny::Catch=REF(0x520def8)') called at
/usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 800
DBIx::Class::Storage::DBI::dbh_do(undef, undef, 'INSERT INTO
PORTAL_USER_ROLE ( client_id, role_id, user_id) V...', 'ARRAY(0x4fa0490)',
'ARRAY(0x533ea30)') called at
/usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 1558

DBIx::Class::Storage::DBI::_execute('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'insert', 'DBIx::Class::ResultSource::Table=HASH(0x4943810)',
'HASH(0x534d2d8)', undef) called at
/usr/local/share/perl5/DBIx/Class/Storage/DBI/MSSQL.pm line 116

DBIx::Class::Storage::DBI::MSSQL::_execute('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'insert', 'DBIx::Class::ResultSource::Table=HASH(0x4943810)',
'HASH(0x534d2d8)', undef) called at
/usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 1671

DBIx::Class::Storage::DBI::insert('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'DBIx::Class::ResultSource::Table=HASH(0x4943810)', 'HASH(0x4f9b328)')
called at /usr/local/share/perl5/DBIx/Class/Storage/DBI/MSSQL.pm line 67

DBIx::Class::Storage::DBI::MSSQL::insert('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::Free...',
'DBIx::Class::ResultSource::Table=HASH(0x4943810)', 'HASH(0x4f9b328)')
called at /usr/local/share/perl5/DBIx/Class/Row.pm line 350

DBIx::Class::Row::insert('Portal::Model::DB::PortalUserRole=HASH(0x4fa0790)')
called at /usr/local/share/perl5/DBIx/Class/Relationship/Base.pm line 604

DBIx::Class::Relationship::Base::create_related('Portal::Model::DB::PortalUser=HASH(0x533ea78)',
'portal_user_roles', 'HASH(0x4f9b130)') called at
/opt/lms/catalyst/Portal/script/../lib/Portal/Controller/Users.pm line 443

Portal::Controller::Users::save('Portal::Controller::Users=HASH(0x4c14790)',
'Portal=HASH(0x4f7fc98)') called at
/usr/local/share/perl5/Catalyst/Action.pm line 65
Catalyst::Action::execute('Catalyst::Action=HASH(0x4df5890)',
'Portal::Controller::Users=HASH(0x4c14790)', 'Portal=HASH(0x4f7fc98)')
called at /usr/local/sha