Re: [Catalyst] Re: javascript in Catalyst using Template Toolkit
On Sat, 2007-12-22 at 09:06 -0500, kevin montuori wrote: > (defun ii-insert-catalyst-url () > (interactive) > (let ((path (read-from-minibuffer "URI: "))) > (insert (format "" path)) > (backward-char 4))) This would be better written as: (defun ii-insert-catalyst-url (path) (interactive "sURI: ") (insert (format "" path)) (backward-char 4)) Now you can call the function non-interactively. Regards, Jonathan Rockway signature.asc Description: This is a digitally signed message part ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Legacy porting to auto-authenticate a logged in user
Thanks for the idea. Didn't work. After following the code trail back through a few namespaces and lots of config v class_data v eyes glaze over, I fixed it by setting the password_type to "none" and merely authenticating on the "username." This is fine in this case but it's obviously less than ideal. If anyone has insight into what I'm doing wrong with my original version, I'd love to hear it. WORKING VERSION (username isn't guaranteed unique so I went with the Id instead): $c->authenticate({ acctid => $user->acctid }) or die "RC_403: " . $user->username . ": " . $user->acctid . " failed to authenticate"; authentication: default_realm: users realms: users: credential: class: Password password_type: none #password_hash_type: SHA-1 #password_field: crypt_passwd store: class: DBIx::Class user_class: DB::User id_field: acctid On Dec 22, 2007, at 3:44 AM, Peter Edwards wrote: Try $c->authenticate({ acctid => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; Regards, Peter -Original Message- From: Ashley Pond V [mailto:[EMAIL PROTECTED] Sent: 22 December 2007 08:08 To: The elegant MVC web framework Subject: [Catalyst] Legacy porting to auto-authenticate a logged in user I have what I first thought was a gimme (this is only tangentially related to the questions I asked a few days ago; same app, different DB and part). Legacy porting of a "login" with Authenticate where I already have the user id and everything verified. I have tried many permutations of arguments and setup. The user has already logged into the legacy part of the app. So this is the code that is not working but I think should. my $user_id = ...legacy fetch; working fine my $user = $c->model("DB::User")->find($user_id) or die "RC_403: No such user for id $user_id"; # also working fine # this dies, I've verified the $user, username, and password are correct $c->authenticate({ username => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; So. why? The legacy setup is a little strange so I think that must be it. The user table's DBIC looks like this (password is plaintext, legacy, and crypt_passwd is sha1 of it)- package MyApp::DB::User; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('foo.account'); __PACKAGE__->add_columns(qw/ acctid email fname lname password crypt_passwd /); __PACKAGE__->set_primary_key('acctid'); sub username { +shift->email; }; My config looks like this- authentication: default_realm: users realms: users: credential: class: Password password_field: crypt_passwd password_type: hashed password_hash_type: SHA-1 store: class: DBIx::Class user_class: DB::User id_field: acctid Thanks for looking! -Ashley ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ [EMAIL PROTECTED]/ 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/ [EMAIL PROTECTED]/ 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/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
RE: [Catalyst] Legacy porting to auto-authenticate a logged in user
Oh well, worth a shot. I had a similar problem and ended up in the bowels of the auth code with the perl debugger to try and figure out the correct params. I also wanted to be able to hook up to a legacy passwd db and it was a bit tricky to get it working. If you want to try this, stick a $DB::single = 1; in your site_perl library Catalyst/Plugin/Authentication.pm in sub authenticate() and then run the test server with perl -d scripts/myapp_server.pl. Use your web browser to try and login, and in the debugger step into the auth handling to see what is going on. There's a page I wrote on using the perl debugger with Catalyst that may help: http://dev.catalyst.perl.org/wiki/DebugSample Regards, Peter http://perl.dragonstaff.co.uk -Original Message- From: Ashley Pond V [mailto:[EMAIL PROTECTED] Sent: 23 December 2007 17:11 To: The elegant MVC web framework Subject: Re: [Catalyst] Legacy porting to auto-authenticate a logged in user Thanks for the idea. Didn't work. After following the code trail back through a few namespaces and lots of config v class_data v eyes glaze over, I fixed it by setting the password_type to "none" and merely authenticating on the "username." This is fine in this case but it's obviously less than ideal. If anyone has insight into what I'm doing wrong with my original version, I'd love to hear it. WORKING VERSION (username isn't guaranteed unique so I went with the Id instead): $c->authenticate({ acctid => $user->acctid }) or die "RC_403: " . $user->username . ": " . $user->acctid . " failed to authenticate"; authentication: default_realm: users realms: users: credential: class: Password password_type: none #password_hash_type: SHA-1 #password_field: crypt_passwd store: class: DBIx::Class user_class: DB::User id_field: acctid On Dec 22, 2007, at 3:44 AM, Peter Edwards wrote: > Try > > $c->authenticate({ acctid => $user->username, >password => $user->password }) > or die "RC_403: " . $user->username . " failed to > authenticate"; > ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] javascript in Catalyst using Template Toolkit
On Fri, Dec 21, 2007 at 11:06:33PM +0100, Daniel McBrearty wrote: > > > > My experience is that every time I think I -can- make that assumption, later > > I end up really wishing I could deploy my app to a sub-URL for testing or > > similar. > > > > You may not have such bad luck, but I don't like to take that chance these > > days :) > > If I hit that one (needing to test code on the real server while an > existing version runs) I typically just run a second server on port > 8080 or something. That makes it completely independent of the running > version (as long as you make sure you use a test database) and lets > you deploy at /. Actually, that wasn't the particular testing case I was thinking of, but the point is there are -lots- of things that turn out to be good reasons for running an app on a sub-URL. Yes, there are workaround for each individual case, but they're all workarounds. Given how little more effort it is, doing things properly in the first place seems like a much better idea to me. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Directorhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Legacy porting to auto-authenticate a logged in user
Hi Ashley, My guess is that your password hashing type in the db is different from the password hashing type you defined for the Password credential. Since your database does store the password in plaintext - why not set password type to 'clear' - and set the password_field to password. This should cause authentication to happen against your unencrypted password and should work. Jay On Dec 23, 2007, at 10:10 AM, Ashley Pond V wrote: Thanks for the idea. Didn't work. After following the code trail back through a few namespaces and lots of config v class_data v eyes glaze over, I fixed it by setting the password_type to "none" and merely authenticating on the "username." This is fine in this case but it's obviously less than ideal. If anyone has insight into what I'm doing wrong with my original version, I'd love to hear it. WORKING VERSION (username isn't guaranteed unique so I went with the Id instead): $c->authenticate({ acctid => $user->acctid }) or die "RC_403: " . $user->username . ": " . $user->acctid . " failed to authenticate"; authentication: default_realm: users realms: users: credential: class: Password password_type: none #password_hash_type: SHA-1 #password_field: crypt_passwd store: class: DBIx::Class user_class: DB::User id_field: acctid On Dec 22, 2007, at 3:44 AM, Peter Edwards wrote: Try $c->authenticate({ acctid => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; Regards, Peter -Original Message- From: Ashley Pond V [mailto:[EMAIL PROTECTED] Sent: 22 December 2007 08:08 To: The elegant MVC web framework Subject: [Catalyst] Legacy porting to auto-authenticate a logged in user I have what I first thought was a gimme (this is only tangentially related to the questions I asked a few days ago; same app, different DB and part). Legacy porting of a "login" with Authenticate where I already have the user id and everything verified. I have tried many permutations of arguments and setup. The user has already logged into the legacy part of the app. So this is the code that is not working but I think should. my $user_id = ...legacy fetch; working fine my $user = $c->model("DB::User")->find($user_id) or die "RC_403: No such user for id $user_id"; # also working fine # this dies, I've verified the $user, username, and password are correct $c->authenticate({ username => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; So. why? The legacy setup is a little strange so I think that must be it. The user table's DBIC looks like this (password is plaintext, legacy, and crypt_passwd is sha1 of it)- package MyApp::DB::User; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('foo.account'); __PACKAGE__->add_columns(qw/ acctid email fname lname password crypt_passwd /); __PACKAGE__->set_primary_key('acctid'); sub username { +shift->email; }; My config looks like this- authentication: default_realm: users realms: users: credential: class: Password password_field: crypt_passwd password_type: hashed password_hash_type: SHA-1 store: class: DBIx::Class user_class: DB::User id_field: acctid Thanks for looking! -Ashley ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ 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/[EMAIL PROTECTED]/ 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/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/ --- America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves. -- Abraham Lincoln ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Legacy porting to auto-authenticate a logged in user
You've hit it. You are better than my Teddy bear lately. I wasn't thinking straight. Since the password is coming from the DB instead of a user form, it's already in SHA1 so it should be treated for the sake of authentication as clear since SHA1 != SHA1(SHA1). Thanks and to Peter for the other ideas for future debuggery, so to speak! -Ashley On Dec 23, 2007, at 10:29 AM, Jay K wrote: Hi Ashley, My guess is that your password hashing type in the db is different from the password hashing type you defined for the Password credential. Since your database does store the password in plaintext - why not set password type to 'clear' - and set the password_field to password. This should cause authentication to happen against your unencrypted password and should work. Jay On Dec 23, 2007, at 10:10 AM, Ashley Pond V wrote: Thanks for the idea. Didn't work. After following the code trail back through a few namespaces and lots of config v class_data v eyes glaze over, I fixed it by setting the password_type to "none" and merely authenticating on the "username." This is fine in this case but it's obviously less than ideal. If anyone has insight into what I'm doing wrong with my original version, I'd love to hear it. WORKING VERSION (username isn't guaranteed unique so I went with the Id instead): $c->authenticate({ acctid => $user->acctid }) or die "RC_403: " . $user->username . ": " . $user->acctid . " failed to authenticate"; authentication: default_realm: users realms: users: credential: class: Password password_type: none #password_hash_type: SHA-1 #password_field: crypt_passwd store: class: DBIx::Class user_class: DB::User id_field: acctid On Dec 22, 2007, at 3:44 AM, Peter Edwards wrote: Try $c->authenticate({ acctid => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; Regards, Peter -Original Message- From: Ashley Pond V [mailto:[EMAIL PROTECTED] Sent: 22 December 2007 08:08 To: The elegant MVC web framework Subject: [Catalyst] Legacy porting to auto-authenticate a logged in user I have what I first thought was a gimme (this is only tangentially related to the questions I asked a few days ago; same app, different DB and part). Legacy porting of a "login" with Authenticate where I already have the user id and everything verified. I have tried many permutations of arguments and setup. The user has already logged into the legacy part of the app. So this is the code that is not working but I think should. my $user_id = ...legacy fetch; working fine my $user = $c->model("DB::User")->find($user_id) or die "RC_403: No such user for id $user_id"; # also working fine # this dies, I've verified the $user, username, and password are correct $c->authenticate({ username => $user->username, password => $user->password }) or die "RC_403: " . $user->username . " failed to authenticate"; So. why? The legacy setup is a little strange so I think that must be it. The user table's DBIC looks like this (password is plaintext, legacy, and crypt_passwd is sha1 of it)- package MyApp::DB::User; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('foo.account'); __PACKAGE__->add_columns(qw/ acctid email fname lname password crypt_passwd /); __PACKAGE__->set_primary_key('acctid'); sub username { +shift->email; }; My config looks like this- authentication: default_realm: users realms: users: credential: class: Password password_field: crypt_passwd password_type: hashed password_hash_type: SHA-1 store: class: DBIx::Class user_class: DB::User id_field: acctid Thanks for looking! -Ashley ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ [EMAIL PROTECTED]/ 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/ [EMAIL PROTECTED]/ 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/ [EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/ --- America will never be destroyed from the outside. If we falter and lose our freedoms, it will be because we destroyed ourselves. -- Abraham Lincoln ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.c
[Catalyst] FastCGI Manager, Apache and SIGPIPE
hi! recently I've put a catalyst website into production using the following config: - apache 2 + fastcgi running in external mode - 1 fastcgi manager with 2 catalyst childs the problem is that randomly, twice a day, the fastcgi manager shuts itself down. the only thing that appears on apache log is "FastCGI: server (pid 8122): safe exit after SIGTERM". To dig more, I put the manager, and both the catalyst children under strace and found this: - the first child (8121) receives a SIG_PIPE, and shuts down 8121 18:17:20 write(4, "\1\6\0\1\26J\6\0\"POST\">\n\t\t\t\t\ttype"..., 5744) = -1 EPIPE (Broken pipe) 8121 18:17:20 --- SIGPIPE (Broken pipe) @ 0 (0) --- (probably the client closed the connection earlier? I have no more data on strace about this process 8121, so it really ends here) - the manager (8120) sees the child dying (8121) and kills the other child (8122) 8120 15:42:58 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGPIPE}], 0) = 8121 8120 18:17:20 --- SIGCHLD (Child exited) @ 0 (0) --- 8120 18:17:20 write(2, "FastCGI: manager (pid 8120): ser"..., 69) = 69 (...) 8120 18:17:20 kill(8122, SIGTERM) = 0 8120 18:17:20 waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 8122 8120 18:17:21 --- SIGCHLD (Child exited) @ 0 (0) --- after this it shuts itself down too... (...) 8120 18:17:21 exit_group(0) Any hint here? Can you point me here's the problem? My bet is that the manager shouldn't abort when a child dies, or maybe catalyst dying on the SIG_PIPE is a bad behavior (or bug). Please advice me. Thank you RĂºben ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/