WebEditor/OldFeatures/WWWAuth.pm

filter: Statementstmt 20.0% 11 / 55 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 3 totaltotal 18.6% 14 / 75 CC 7 SCAR 26.2
CC
7
Cov
17%
update_auth_files
30.0
wwwauthedit
6.0
get_wwwauth_user_db
6.0
CRAP 13.8
« WE_Content/XML.pm ↑ Summary WE_Frontend/Plugin/HTMLFromText.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: WWWAuth.pm,v 1.3 2004/04/08 14:24:47 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2004 Slaven Rezic. All rights reserved.
8 # This package is free software; you can redistribute it and/or
9 # modify it under the same terms as Perl itself.
10 #
11 # Mail: eserte@users.sourceforge.net
12 # WWW: http://www.sourceforge.net/projects/we-framework
13 #
14  
15 package WebEditor::OldFeatures::WWWAuth;
16  
17 =head1 NAME
18  
19 WebEditor::OldFeatures::WWWAuth -
20  
21 =head1 SYNOPSIS
22  
23  
24 =head1 DESCRIPTION
25  
26  
27 =head1 AUTHOR
28  
29 Slaven Rezic.
30  
31 =cut
32  
33 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
36  
37 1 ▶use mixin::with 'WebEditor::OldController';
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 0 ▶sub wwwauthedit {
Subroutine wwwauthedit: not called CC=2 SCAR=17.9
Pod undocumented
40 0 my $self = shift;
41 0 my $root = $self->Root;
42 0 my($all_users_js, $all_groups_js);
43 0 my $c = $self->C;
44 0 ▶ if ($c->project->features->{"wwwauth"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->project->features->{'wwwauth'}) { } 0 0 0
45 0 my $u = $self->get_wwwauth_user_db;
46 0 require Data::JavaScript;
47 $all_users_js = join "\n", Data::JavaScript::jsdump
48 ("all_users",
49 0 [ map { $u->get_user($_) } sort $u->get_all_users ]
50 );
51 # XXX output of get_all_groups is wrong!
52 $all_groups_js = join "\n", Data::JavaScript::jsdump
53 ("all_groups",
54 0 [ map { +{ groupname => $_ } } sort $u->get_all_groups ]
55 );
56 } else {
57 0 $all_users_js = "all_users = [];\n";
58 0 $all_groups_js = "all_groups = [];\n";
59 }
60  
61 0 $self->_tpl("bestwe", "we_wwwauthedit.tpl.html",
62 {
63 'message' => undef,
64 'all_users_js' => $all_users_js,
65 'all_groups_js' => $all_groups_js,
66 }
67 );
68 }
69  
70 0 ▶sub update_auth_files {
Subroutine update_auth_files: not called CC=5 SCAR=34.0
Pod undocumented
71 0 my $self = shift;
72 0 my(%args) = @_;
73 0 my $v = $args{-verbose};
74 # XXX do I have to check for -userdb option?
75 0 my $c = $self->C;
76 0 my $userdb = $self->get_wwwauth_user_db;
77 0 my $root = $self->Root;
78 0 my $objdb = $root->ObjDB;
79 0 require WE::Util::Htaccess;
80 0 require WE::Util::Htpasswd;
81 0 require WE::Util::Htgroup;
82 0 for my $lang (@{ $c->project->sitelanguages }) {
83 0 my $dir = $c->paths->pubhtmldir . "/html/$lang";
84 0 my $passwd = "$dir/.htpasswd";
85 0 my $group = "$dir/.htgroup";
86 0 my $access = "$dir/.htaccess";
87 0 ▶ warn "Creating user passwd file $passwd...\n" if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
88 0 WE::Util::Htpasswd::create($passwd, $userdb);
89 0 ▶ warn "Creating group file $group...\n" if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
90 0 WE::Util::Htgroup::create($group, $userdb);
91 0 ▶ warn "Creating access file $access...\n" if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 0 0
92 WE::Util::Htaccess::create($access, $objdb,
93 -authname => $c->project->name,#longname? XXX
94 -authuserfile => $passwd,
95 -authgroupfile => $group,
96 -inherit => 1,
97 0 ▶ -getaliases => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 # XXX where to supply -now parameter?
99 0 $self->get_alias_pages($_[0]);
100 },
101 #XXX -add errordocument, see pod
102 0 );
103 }
104 }
105  
106 0 ▶sub get_wwwauth_user_db {
Subroutine get_wwwauth_user_db: not called CC=2 SCAR=17.9
Pod undocumented
107 0 my $self = shift;
108 0 my $c = $self->C;
109 0 my($type, $userdb) = split /:/, $c->project->features->{"wwwauth"};
110 0 ▶ if ($type ne "db") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "db") 0 0 0
111 0 die "Only support for wwwauth database db";
112 }
113 0 my $u = $self->get_custom_userdb($userdb);
114 0 $u;
115 }
116  
117 1 1;
« WE_Content/XML.pm ↑ Summary WE_Frontend/Plugin/HTMLFromText.pm »