Skip to content

Commit 2ad2fa8

Browse files
committed
Initial commit for Issue #1120 - Adding remote auth endpoints
- All endpoints added - Files stubbed for unit/functional tests Issue #1120 - functional tests complete Issue #1120 - unit tests complete Issue #1120 - flake8 errors fixed Updated remote-role functional test case to reflect error message change
1 parent db94592 commit 2ad2fa8

25 files changed

Lines changed: 1202 additions & 0 deletions

f5/bigip/tm/auth/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,32 @@
2929

3030

3131
from f5.bigip.resource import OrganizingCollection
32+
from f5.bigip.tm.auth.cert_ldap import Cert_Ldaps
33+
from f5.bigip.tm.auth.ldap import Ldaps
3234
from f5.bigip.tm.auth.partition import Partitions
3335
from f5.bigip.tm.auth.password_policy import Password_Policy
36+
from f5.bigip.tm.auth.radius import Radius_s
37+
from f5.bigip.tm.auth.radius_server import Radius_Servers
38+
from f5.bigip.tm.auth.remote_role import Remote_Role
39+
from f5.bigip.tm.auth.remote_user import Remote_User
40+
from f5.bigip.tm.auth.source import Source
41+
from f5.bigip.tm.auth.tacacs import Tacacs_s
3442
from f5.bigip.tm.auth.user import Users
3543

3644

3745
class Auth(OrganizingCollection):
3846
def __init__(self, tm):
3947
super(Auth, self).__init__(tm)
4048
self._meta_data['allowed_lazy_attributes'] = [
49+
Cert_Ldaps,
50+
Ldaps,
4151
Partitions,
4252
Password_Policy,
53+
Radius_s,
54+
Radius_Servers,
55+
Remote_Role,
56+
Remote_User,
57+
Source,
58+
Tacacs_s,
4359
Users
4460
]

f5/bigip/tm/auth/cert_ldap.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/cert-ldap``
22+
23+
GUI Path
24+
``System --> Users --> Authentication``
25+
26+
REST Kind
27+
``tm:auth:cert-ldap:*``
28+
"""
29+
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import Resource
32+
from f5.sdk_exception import InvalidName
33+
34+
35+
class Cert_Ldaps(Collection):
36+
"""BIG-IP® ldap server collection"""
37+
def __init__(self, auth):
38+
super(Cert_Ldaps, self).__init__(auth)
39+
self._meta_data['allowed_lazy_attributes'] = [Cert_Ldap]
40+
self._meta_data['attribute_registry'] = \
41+
{'tm:auth:cert-ldap:cert-ldapstate': Cert_Ldap}
42+
43+
44+
class Cert_Ldap(Resource):
45+
"""BIG-IP® ldap server resource"""
46+
def __init__(self, cert_ldaps):
47+
super(Cert_Ldap, self).__init__(cert_ldaps)
48+
self._meta_data['required_json_kind'] = \
49+
'tm:auth:cert-ldap:cert-ldapstate'
50+
51+
def create(self, **kwargs):
52+
"""name has to be system-auth, raise error if not named correctly"""
53+
if 'name' in kwargs:
54+
if kwargs['name'] != 'system-auth':
55+
raise InvalidName("Name must be 'system-auth'")
56+
return self._create(**kwargs)

f5/bigip/tm/auth/ldap.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/ldap``
22+
23+
GUI Path
24+
``System --> Users --> Authentication``
25+
26+
REST Kind
27+
``tm:auth:ldap:*``
28+
"""
29+
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import Resource
32+
from f5.sdk_exception import InvalidName
33+
34+
35+
class Ldaps(Collection):
36+
"""BIG-IP® ldap server collection"""
37+
def __init__(self, auth):
38+
super(Ldaps, self).__init__(auth)
39+
self._meta_data['allowed_lazy_attributes'] = [Ldap]
40+
self._meta_data['attribute_registry'] = \
41+
{'tm:auth:ldap:ldapstate': Ldap}
42+
43+
44+
class Ldap(Resource):
45+
"""BIG-IP® ldap server resource"""
46+
def __init__(self, ldaps):
47+
super(Ldap, self).__init__(ldaps)
48+
self._meta_data['required_json_kind'] = 'tm:auth:ldap:ldapstate'
49+
50+
def create(self, **kwargs):
51+
"""name has to be system-auth, raise error if not named correctly"""
52+
if 'name' in kwargs:
53+
if kwargs['name'] != 'system-auth':
54+
raise InvalidName("Name must be 'system-auth'")
55+
return self._create(**kwargs)

f5/bigip/tm/auth/radius.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/radius``
22+
23+
GUI Path
24+
``System --> Users --> Authentication``
25+
26+
REST Kind
27+
``tm:auth:radius:*``
28+
"""
29+
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import Resource
32+
from f5.sdk_exception import InvalidName
33+
34+
35+
class Radius_s(Collection):
36+
"""BIG-IP® tacacs server collection"""
37+
def __init__(self, auth):
38+
super(Radius_s, self).__init__(auth)
39+
self._meta_data['allowed_lazy_attributes'] = [Radius]
40+
self._meta_data['attribute_registry'] = \
41+
{'tm:auth:radius:radiusstate': Radius}
42+
43+
44+
class Radius(Resource):
45+
"""BIG-IP® tacacs server resource"""
46+
def __init__(self, radius_s):
47+
super(Radius, self).__init__(radius_s)
48+
self._meta_data['required_json_kind'] = 'tm:auth:radius:radiusstate'
49+
50+
def create(self, **kwargs):
51+
"""name has to be system-auth, raise error if not named correctly"""
52+
if 'name' in kwargs:
53+
if kwargs['name'] != 'system-auth':
54+
raise InvalidName("Name must be 'system-auth'")
55+
return self._create(**kwargs)

f5/bigip/tm/auth/radius_server.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/radius-server``
22+
23+
GUI Path
24+
``System --> Users --> Authentication``
25+
26+
REST Kind
27+
``tm:auth:radius-server:*``
28+
"""
29+
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import Resource
32+
33+
34+
class Radius_Servers(Collection):
35+
"""BIG-IP® tacacs server collection"""
36+
def __init__(self, auth):
37+
super(Radius_Servers, self).__init__(auth)
38+
self._meta_data['allowed_lazy_attributes'] = [Radius_Server]
39+
self._meta_data['attribute_registry'] = \
40+
{'tm:auth:radius-server:radius-serverstate': Radius_Server}
41+
42+
43+
class Radius_Server(Resource):
44+
"""BIG-IP® tacacs server resource"""
45+
def __init__(self, radius_servers):
46+
super(Radius_Server, self).__init__(radius_servers)
47+
self._meta_data['required_json_kind'] = \
48+
'tm:auth:radius-server:radius-serverstate'

f5/bigip/tm/auth/remote_role.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/remote-role``
22+
23+
GUI Path
24+
``System --> Users --> Remote Role Groups``
25+
26+
REST Kind
27+
``tm:auth:remote-role:*``
28+
"""
29+
30+
from f5.bigip.resource import Collection
31+
from f5.bigip.resource import Resource
32+
from f5.bigip.resource import UnnamedResource
33+
from f5.sdk_exception import UnsupportedOperation
34+
35+
36+
class Remote_Role(UnnamedResource):
37+
"""BIG-IP® auth remote role resource"""
38+
def __init__(self, auth):
39+
super(Remote_Role, self).__init__(auth)
40+
self._meta_data['allowed_lazy_attributes'] = [Role_Infos]
41+
self._meta_data['required_json_kind'] = \
42+
'tm:auth:remote-role:remote-rolestate'
43+
self._meta_data['attribute_registry'] = \
44+
{'tm:auth:remote-role:role-info:role-infocollectionstate': Role_Infos}
45+
46+
47+
class Role_Infos(Collection):
48+
"""BIG-IP® remote role role-info collection"""
49+
def __init__(self, auth):
50+
super(Role_Infos, self).__init__(auth)
51+
self._meta_data['allowed_lazy_attributes'] = [Role_Info]
52+
self._meta_data['required_json_kind'] = \
53+
'tm:auth:remote-role:role-info:role-infocollectionstate'
54+
self._meta_data['attribute_registry'] = \
55+
{'tm:auth:remote-role:role-info:role-infostate': Role_Info}
56+
57+
58+
class Role_Info(Resource):
59+
"""BIG-IP® remote role role-info resource"""
60+
def __init__(self, role_infos):
61+
super(Role_Info, self).__init__(role_infos)
62+
self._meta_data['required_json_kind'] = \
63+
'tm:auth:remote-role:role-info:role-infostate'
64+
65+
def update(self, **kwargs):
66+
'''Update is not supported for Auth Remote Role - Role Info Objects
67+
68+
:raises: UnsupportedOperation
69+
'''
70+
raise UnsupportedOperation(
71+
"%s does not support update, use modify instead" % self.__class__.__name__
72+
)

f5/bigip/tm/auth/remote_user.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2017 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® auth module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/auth/remote-user``
22+
23+
GUI Path
24+
``System --> Users --> Authentication``
25+
26+
REST Kind
27+
``tm:auth:remote-user:*``
28+
"""
29+
30+
from f5.bigip.resource import UnnamedResource
31+
32+
33+
class Remote_User(UnnamedResource):
34+
"""BIG-IP® auth source resource"""
35+
def __init__(self, auth):
36+
super(Remote_User, self).__init__(auth)
37+
self._meta_data['required_json_kind'] = \
38+
'tm:auth:remote-user:remote-userstate'

0 commit comments

Comments
 (0)