-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Role Permissions.
- Loading branch information
Showing
21 changed files
with
216 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ Net::Etcd::Auth | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::Auth::Role | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
use utf8; | ||
package Net::Etcd::Auth::RolePermission; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moo; | ||
use Types::Standard qw(Str Int Bool HashRef ArrayRef); | ||
use MIME::Base64; | ||
use Carp; | ||
use JSON; | ||
use Data::Dumper; | ||
|
||
with 'Net::Etcd::Role::Actions'; | ||
|
||
use namespace::clean; | ||
|
||
=head1 NAME | ||
Net::Etcd::Auth::RolePermission | ||
=cut | ||
|
||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
Permission | ||
=head2 endpoint | ||
=cut | ||
|
||
has endpoint => ( | ||
is => 'ro', | ||
isa => Str, | ||
); | ||
|
||
=head2 name | ||
name of role | ||
=cut | ||
|
||
has name => ( | ||
is => 'ro', | ||
isa => Str, | ||
); | ||
|
||
=head2 role | ||
name of role | ||
* only used in revoke, use name for grant... not my idea. | ||
=cut | ||
|
||
has role => ( | ||
is => 'ro', | ||
isa => Str, | ||
); | ||
|
||
=head2 key | ||
name of key | ||
=cut | ||
|
||
has key => ( | ||
is => 'ro', | ||
isa => Str, | ||
required => 1, | ||
coerce => sub { return encode_base64( $_[0], '' ) }, | ||
); | ||
|
||
=head2 range_end | ||
End of key range | ||
=cut | ||
|
||
has range_end => ( | ||
is => 'ro', | ||
isa => Str, | ||
coerce => sub { return encode_base64( $_[0], '' ) }, | ||
); | ||
|
||
=head2 permType | ||
valid options are READ, WRITE, and READWRITE | ||
=cut | ||
|
||
has permType =>( | ||
is => 'ro', | ||
isa => Str, | ||
); | ||
|
||
=head2 perm | ||
Perm | ||
=cut | ||
|
||
has perm => ( | ||
is => 'lazy', | ||
); | ||
|
||
sub _build_perm { | ||
my ($self) = @_; | ||
my $perm; | ||
for my $key ( keys %{$self} ) { | ||
unless ( $key =~ /(?:name|etcd|cb|endpoint)$/ ) { | ||
$perm->{$key} = $self->{$key}; | ||
} | ||
} | ||
return $perm; | ||
} | ||
|
||
=head2 grant | ||
Grant permission to role | ||
=cut | ||
|
||
sub grant {; | ||
my ($self) = @_; | ||
$self->{endpoint} = '/auth/role/grant'; | ||
$self->{json_args} = to_json( {name => $self->name, perm => $self->perm } ); | ||
$self->request; | ||
return $self; | ||
} | ||
|
||
=head2 revoke | ||
Revoke permission to role | ||
=cut | ||
|
||
sub revoke {; | ||
my ($self) = @_; | ||
$self->{endpoint} = '/auth/role/revoke'; | ||
$self->request; | ||
return $self; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ Net::Etcd::Config | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 ACCESSORS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ Net::Etcd::KV | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::KV::Compare | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::KV::Op | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ Net::Etcd::Put | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::Range | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::KV::Txn | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::Lease | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ Net::Etcd::Maintenance | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::User | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ Net::Etcd::User::Role | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ Net::Etcd::Range | |
=cut | ||
|
||
our $VERSION = '0.012'; | ||
our $VERSION = '0.013'; | ||
|
||
=head1 DESCRIPTION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.