Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for lists via pts query

  • Loading branch information...
commit 4729a1e2d573b8bfb943f51c3d19b23d395cdc2b 1 parent 6e4d98c
@austein austein authored committed
Showing with 26 additions and 2 deletions.
  1. +9 −1 lib/AuthMitEdu/Dispatcher.pm
  2. +17 −1 lib/AuthMitEdu/Model/User.pm
View
10 lib/AuthMitEdu/Dispatcher.pm
@@ -3,6 +3,8 @@ package AuthMitEdu::Dispatcher;
use Jifty::Dispatcher -base;
before '*' => run {
+ use Data::Dumper;
+ warn Dumper(\%ENV);
if(!Jifty->web->current_user->id) {
my $user = AuthMitEdu::Model::User->remote_user;
if($user) {
@@ -17,7 +19,13 @@ on '/error/bad_identity/**' => run {
show '/error/bad_identity';
};
-on qr{^/([a-zA-Z][a-zA-Z_0-9]+)$} => run {
+on qr{^/group/([a-zA-Z_\-0-9]+)$} => run{
+ set user=> $1;
+ show '/endpoint';
+ last_rule;
+};
+
+on qr{^/([a-zA-Z][a-zA-Z_\-0-9]+)$} => run {
set user => $1;
show '/endpoint';
};
View
18 lib/AuthMitEdu/Model/User.pm
@@ -35,7 +35,23 @@ sub remote_user {
sub is_identity {
my ($self, $url) = @_;
$url = URI->new($url);
- return $url->path eq '/' . $self->username;
+ if($url->path =~ /\/group\/./) {
+ my ($groupname) = $url->path =~ /\/group\/([a-zA-Z_\-0-9]+)/;
+ my $groupsystem = "system:" . $groupname;
+ my $ptsmem = `pts 2>/dev/null membership $groupsystem`;
+ my @ptsmem = split(/\n/, $ptsmem);
+ unless($ptsmem[0] =~ /^Members of $groupsystem \(id: \S+\) are:$/) {
+ return 0;
+ }
+ my $theuser = $self->username;
+ for(my $i = 1; $i < @ptsmem; $i++) {
+ if($ptsmem[$i] =~ /\s$theuser$/) {
+ return 1;
+ }
+ }
+ } {
+ return $url->path eq '/' . $self->username;
+ }
}
sub trusts_root {
Please sign in to comment.
Something went wrong with that request. Please try again.