Mercurial > pub > Impl
comparison Lib/IMPL/Web/Security.pm @ 393:69a1f1508696
minor security refactoring
| author | cin |
|---|---|
| date | Fri, 14 Feb 2014 16:41:12 +0400 |
| parents | 2287c72f303a |
| children |
comparison
equal
deleted
inserted
replaced
| 392:54b1dc9e808a | 393:69a1f1508696 |
|---|---|
| 17 ERR_NO_AUTHORITY => -3, | 17 ERR_NO_AUTHORITY => -3, |
| 18 ERR_NO_SEC_CONTEXT => -4, | 18 ERR_NO_SEC_CONTEXT => -4, |
| 19 ERR_AUTH_FAIL => -5 | 19 ERR_AUTH_FAIL => -5 |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 sub interactiveAuthPackage { | |
| 23 die NotImplementedException->new(); | |
| 24 } | |
| 25 | |
| 26 sub users { | |
| 27 die NotImplementedException->new(); | |
| 28 } | |
| 29 | |
| 30 sub roles { | |
| 31 die die NotImplementedException->new(); | |
| 32 } | |
| 33 | |
| 34 sub sessions { | |
| 35 die NotImplementedException->new(); | |
| 36 } | |
| 37 | |
| 22 sub AuthUser { | 38 sub AuthUser { |
| 23 my ($this,$name,$challenge,$package) = @_; | 39 my ($this,$name,$challenge,$roles,$package) = @_; |
| 24 | 40 |
| 25 $package ||= $this->interactiveAuthPackage; | 41 $package ||= $this->interactiveAuthPackage; |
| 42 $roles ||= []; | |
| 26 | 43 |
| 27 my $user = $this->users->GetById($name) | 44 my $user = $this->users->GetById($name) |
| 28 or return { | 45 or return { |
| 29 status => AUTH_FAIL, | 46 status => AUTH_FAIL, |
| 30 code => ERR_NO_SUCH_USER | 47 code => ERR_NO_SUCH_USER |
| 51 code => ERR_NO_AUTHORITY | 68 code => ERR_NO_AUTHORITY |
| 52 } unless SecurityContext->current->authority; | 69 } unless SecurityContext->current->authority; |
| 53 | 70 |
| 54 my $status = SecurityContext->current->authority->InitSession( | 71 my $status = SecurityContext->current->authority->InitSession( |
| 55 $user, | 72 $user, |
| 56 [$user->roles], | 73 $roles, |
| 57 $auth, | 74 $auth, |
| 58 $challenge | 75 $challenge |
| 59 ); | 76 ); |
| 60 | 77 |
| 61 return { | 78 return { |
