The Command Line Interpreter (CLI) drives the admin and review APIs, allowing ad-hoc RBAC setup and interrogation. More info in the README.
Prerequisites
Completed the setup described: py-fortress Jumpstart
Getting Started
The command syntax:
python3 cli.py entityoperation --arg1 --arg2 ...
Where entity is (pick one):
The operation is (pick one):
- add
- mod
- del
- assign
- deassign
- grant
- revoke
- read
- search
The arguments are two dashes ‘- -‘ plus the attribute name and value pair, with a space between them.
--attribute_name someattributevalue
if an attribute value contains white space, enclose in single ‘ ‘ or double tics ” “.
--attribute_name 'some value' --attribute_name2 "still more values"
For example, a perm grant:
$ python3 cli.py perm grant --obj_name myobj --op_name add --role 'my role'
This command invokes Python’s runtime with the program name, cli.py, followed by an entity type, operation name and multiple name-value pairs.
More Tips:
- user and perm entities require the –role arg on assign, deassign, grant, and revoke operations.
- These commands map directly to the admin and review APIs.
- The description of the commands, including required arguments, can be inferred via the api doc inline to the admin_mgr and review_mgr modules.
- The program output echos the inputted arguments and the results.
admin mgr
a. user add
$ python3 cli.py user add --uid chorowitz --password 'secret' --description 'added with py-fortress cli'
uid=chorowitz
description=added with py-fortress cli
user add
success
b. user mod
$ python3 cli.py user mod --uid chorowitz --l my location --ou my-ou --department_number 123
uid=chorowitz
department_number=123
l=my location
ou=my-ou
user mod
success
c. user del
$ python3 cli.py user del --uid chorowitz
uid=chorowitz
user del
success
d. user assign
$ python3 cli.py user assign --uid chorowitz --role account-mgr
uid=chorowitz
role name=account-mgr
user assign
success
e. user deassign
$ python3 cli.py user deassign --uid chorowitz --role account-mgr
uid=chorowitz
role name=account-mgr
user deassign
success
f. role add
$ python3 cli.py role add --name account-mgr
name=account-mgr
role add
success
g. role mod
$ python3 cli.py role mod --name account-mgr --description 'this desc is optional'
description=cli test role
name=account-mgr
role mod
success
h. role del
$ python3 cli.py role del --name account-mgr
name=account-mgr
role del
success
i. object add
$ python3 cli.py object add --obj_name page456
obj_name=page456
object add
success
j. object mod
$ python3 cli.py object mod --obj_name page456 --description 'optional arg' --ou 'another optional arg'
obj_name=page456
ou=another optional arg
description=optional arg
object mod
success
k. object del
$ python3 cli.py object del --obj_name page789
obj_name=page789
object del
success
l. perm add
$ python3 cli.py perm add --obj_name page456 --op_name read
obj_name=page456
op_name=read
perm add
success
m. perm mod
$ python3 cli.py perm mod --obj_name page456 --op_name read --description 'useful for human readable perm name'
obj_name=page456
op_name=read
description=useful for human readable perm name
perm mod
success
n. perm del
$ python3 cli.py perm del --obj_name page456 --op_name search
obj_name=page456
op_name=search
perm del
success
o. perm grant
$ python3 cli.py perm grant --obj_name page456 --op_name update --role account-mgr
obj_name=page456
op_name=update
role name=account-mgr
perm grant
success
p. perm revoke
$ python3 cli.py perm revoke --obj_name page456 --op_name update --role account-mgr
obj_name=page456
op_name=update
role name=account-mgr
perm revoke
success
review mgr
a. user read
$ python3 cli.py user read --uid chorowitz
uid=chorowitz
user read
chorowitz
uid: chorowitz
dn: uid=chorowitz,ou=People,dc=example,dc=com
roles: ['account-mgr']
...
*************** chorowitz *******************
success
b. user search
$ python3 cli.py user search --uid c
uid=c
user search
c*:0
uid: canders
dn: uid=canders,ou=People,dc=example,dc=com
roles: ['csr', 'tester']
...
*************** c*:0 *******************
c*:1
uid: cedwards
dn: uid=cedwards,ou=People,dc=example,dc=com
roles: ['manager', 'trainer']
...
*************** c*:1 *******************
c*:2
uid: chandler
dn: uid=chandler,ou=People,dc=example,dc=com
roles: ['auditor']
...
*************** c*:2 *******************
c*:3
uid: chorowitz
dn: uid=chorowitz,ou=People,dc=example,dc=com
roles: ['account-mgr']
...
*************** c*:3 *******************
success
c. role read
$ python3 cli.py role read --name account-mgr
name=account-mgr
role read
account-mgr
dn: cn=account-mgr,ou=Roles,dc=example,dc=com
props:
members: ['uid=cli-user2,ou=People,dc=example,dc=com', 'uid=chorowitz,ou=People,dc=example,dc=com']
internal_id: 5c189235-41b5-4e59-9d80-dfd64d16372c
name: account-mgr
constraint: <model.constraint.Constraint object at 0x7fc250bd9e10>
description:
Role Constraint:
raw: account-mgr$0$$$$$$$
end_date:
end_lock_date:
timeout: 0
begin_time:
end_time:
name: account-mgr
day_mask:
begin_date:
begin_lock_date:
*************** account-mgr *******************
success
d. role search
$ python3 cli.py role search --name py-
name=py-
role search
py-*:0
dn: cn=py-role-0,ou=Roles,dc=example,dc=com
description: py-role-0 Role
constraint: <model.constraint.Constraint object at 0x7f17e8745f60>
members: ['uid=py-user-0,ou=People,dc=example,dc=com', 'uid=py-user-1,ou=People,dc=example,dc=com', ... ]
internal_id: 04b82ce3-974b-4ff5-ad21-b19ecca57722
name: py-role-0
*************** py-*:0 *******************
py-*:1
dn: cn=py-role-1,ou=Roles,dc=example,dc=com
description: py-role-1 Role
constraint: <model.constraint.Constraint object at 0x7f17e8733128>
members: ['uid=py-user-8,ou=People,dc=example,dc=com', 'uid=py-user-9,ou=People,dc=example,dc=com']
internal_id: 70524da8-3be6-4372-a606-d8175e2ca63b
name: py-role-1
*************** py-*:1 *******************
py-*:2
dn: cn=py-role-2,ou=Roles,dc=example,dc=com
description: py-role-2 Role
constraint: <model.constraint.Constraint object at 0x7f17e87332b0>
members: ['uid=py-user-3,ou=People,dc=example,dc=com', 'uid=py-user-5,ou=People,dc=example,dc=com', 'uid=py-user-7,ou=People,dc=example,dc=com']
internal_id: d1b9da70-9302-46c3-b21b-0fc45b863155
name: py-role-2
*************** py-*:2 *******************
...
success
e. object read
$ python3 cli.py object read --obj_name page456
obj_name=page456
object read
page456
description: optional arg
dn: ftObjNm=page456,ou=Perms,dc=example,dc=com
internal_id: 1635cb3b-d5e2-4fcb-b61a-b8e91437e536
props:
obj_name: page456
ou: another optional arg
type:
success
f. object search
$ python3 cli.py object search --obj_name page
obj_name=page
object search
page*:0
props:
obj_name: page456
description: optional arg
dn: ftObjNm=page456,ou=Perms,dc=example,dc=com
ou: another optional arg
type:
internal_id: 1635cb3b-d5e2-4fcb-b61a-b8e91437e536
page*:1
props:
obj_name: page123
description: optional arg
dn: ftObjNm=page123,ou=Perms,dc=example,dc=com
ou: another optional arg
type:
internal_id: a823ef98-7be4-4f49-a805-83bfef5a0dfb
success
g. perm read
$ python3 cli.py perm read --obj_name page456 --op_name read
op_name=read
obj_name=page456
perm read
page456.read
internal_id: 0dc55181-968e-4c60-8755-e20fa1ce017d
dn: ftOpNm=read,ftObjNm=page456,ou=Perms,dc=example,dc=com
abstract_name: page456.read
type:
roles:
description: useful for human readable perm name
props:
obj_name: page456
obj_id:
op_name: read
users:
success
h. perm search
$ python3 cli.py perm search --obj_name page
obj_name=page
perm search
page*.*:0
props:
roles:
abstract_name: page456.read
obj_id:
users:
op_name: read
internal_id: 0dc55181-968e-4c60-8755-e20fa1ce017d
obj_name: page456
type:
dn: ftOpNm=read,ftObjNm=page456,ou=Perms,dc=example,dc=com
description: useful for human readable perm name
page*.*:1
props:
roles: ['account-mgr']
abstract_name: page456.update
obj_id:
users:
op_name: update
internal_id: 626bca86-014b-4186-83a6-a583e39868a1
obj_name: page456
type:
dn: ftOpNm=update,ftObjNm=page456,ou=Perms,dc=example,dc=com
description:
page*.*:2
props:
roles: ['account-mgr']
abstract_name: page456.delete
obj_id:
users:
op_name: delete
internal_id: 6c2fa5fc-d7c3-4e85-ba7f-5e514ca4263f
obj_name: page456
type:
dn: ftOpNm=delete,ftObjNm=page456,ou=Perms,dc=example,dc=com
description:
success
i. perm search (by role)
$ python3 cli.py perm search --role account-mgr
perm search
account-mgr:0
description:
abstract_name: page456.update
obj_id:
obj_name: page456
users:
op_name: update
type:
props:
roles: ['account-mgr']
dn: ftOpNm=update,ftObjNm=page456,ou=Perms,dc=example,dc=com
internal_id: 626bca86-014b-4186-83a6-a583e39868a1
account-mgr:1
description:
abstract_name: page456.delete
obj_id:
obj_name: page456
users:
op_name: delete
type:
props:
roles: ['account-mgr']
dn: ftOpNm=delete,ftObjNm=page456,ou=Perms,dc=example,dc=com
internal_id: 6c2fa5fc-d7c3-4e85-ba7f-5e514ca4263f
success
j. perm search (by user)
$ python3 cli.py perm search --uid chorowitz
perm search
chorowitz:0
type:
description:
dn: ftOpNm=update,ftObjNm=page456,ou=Perms,dc=example,dc=com
obj_id:
users:
internal_id: 626bca86-014b-4186-83a6-a583e39868a1
roles: ['account-mgr']
abstract_name: page456.update
props:
obj_name: page456
op_name: update
chorowitz:1
type:
description:
dn: ftOpNm=delete,ftObjNm=page456,ou=Perms,dc=example,dc=com
obj_id:
users:
internal_id: 6c2fa5fc-d7c3-4e85-ba7f-5e514ca4263f
roles: ['account-mgr']
abstract_name: page456.delete
props:
obj_name: page456
op_name: delete
success
END
Next up, programming with py-fortress