Commit Graph

108 Commits

Author SHA1 Message Date
Ryan Petrello
82e41b40bb enforce strings for secret password inputs on Credentials
see: https://github.com/ansible/ansible-tower/issues/7898
2018-02-12 17:03:32 -05:00
AlanCoding
018514d657 urlencode unquote host_filter on save 2017-10-24 08:05:08 -04:00
Ryan Petrello
63273d8ffd filter Python unicode string prefix from jsonschema validation errors.
see: https://github.com/ansible/ansible-tower/issues/6417
2017-07-31 15:22:19 -04:00
Ryan Petrello
5e15f9e04e add validation errors for certain dependent credential fields
see: https://github.com/ansible/ansible-tower/issues/7323
see: https://github.com/ansible/ansible-tower/issues/7293
see: https://github.com/ansible/ansible-tower/issues/7289
see: https://github.com/ansible/ansible-tower/issues/7292
2017-07-28 16:07:37 -04:00
Ryan Petrello
c71e8d38b7 improve private passphrase error when it's provided unnecessarily
see: https://github.com/ansible/ansible-tower/issues/7293
2017-07-26 15:04:10 -04:00
Ryan Petrello
9f11c008d2 don't allow boolean credential type fields that specify secret
secret doesn't really make sense for boolean values; they can't store
sensitive content because they're just true|false

see: https://github.com/ansible/ansible-tower/issues/6776
2017-07-24 11:41:12 -04:00
Ryan Petrello
a640d6afec improve sanitation of empty credential values to match API v1 behavior
This is mostly backwards compatability to avoid surprises: in 3.1.x
if you submit a field value with `null` or an empty string to
a CharField, it's treated as an empty string (and SSH key validation
is skipped).  For boolean field values (`net.authorize`), `null` and
empty string are coerced to `False`.

see: #7216
see: #7218
2017-07-21 11:25:56 -04:00
Ryan Petrello
afb307c146 properly validate choices for credential input validation
see: #7119
2017-07-17 16:58:33 -04:00
Ryan Petrello
dade5c12a7 fix a bug in the CredentialType field validator that breaks required
see: #6769
2017-06-30 12:27:43 -04:00
Ryan Petrello
12982d6ef6 Merge pull request #6541 from wwitzel3/issue-826
Re-Encrypt all of our existing encrypted fields.
2017-06-13 09:42:56 -04:00
Ryan Petrello
240d629128 fix a bug in ssh key unlock validation
see: #6553
2017-06-12 10:28:38 -04:00
Wayne Witzel III
b5d61c3c53 Relocate encryption helpers, update settings, tests, and imports 2017-06-12 09:54:12 -04:00
Ryan Petrello
28ad576c90 properly validate ssh_key_unlock for Net and SCM credentials
see: #6460
2017-06-09 10:43:04 -04:00
Ryan Petrello
af457ad8eb clarify valid CredentialType field types
almost all of our current credential values are strings, but under the
v1 Credential model, `authorize` is boolean

additionally, if a field is specified with no type, fall back to
`string` as a default (this is almost always what people creating custom
types will want)

see: #6406
2017-06-01 13:23:51 -04:00
Ryan Petrello
e0a629db58 improve error formatting for jsonschema failures on Credential.inputs
this provides error messages keyed by input fields, so that instead of
e.g.,

{
    'inputs': ['Invalid certificate or key: u'XYZ']
}

...you get:

{
    'inputs': {
        'ssh_key_data': ['Invalid certificate or key: u'XYZ']
    }
}

Includes /api/v1/ compatability for error message format.  Requests to
/api/v1/ will get:

{'ssh_key_data': ['Invalid certificate or key: u'XYZ']}
2017-06-01 09:48:42 -04:00
Ryan Petrello
98fa654be2 enforce dict for credential API input payloads
see: #6363
2017-06-01 09:19:21 -04:00
Wayne Witzel III
d652ed16d0 Dynamic -> Smart Inventory 2017-05-17 16:25:40 -04:00
Ryan Petrello
0ac4f71e5b refactor and fix ssh_private_key and ssh_key_unlock validation
`clean_ssh_key_data` and `clean_ssh_key_unlock` no longer work because
they're not actual fields on `model.Credential` anymore.  This change
refactors/moves their validation to a place that works (and makes more
sense).
2017-05-12 09:42:29 -04:00
Ryan Petrello
ef09744b75 enforce variable name syntax and uniqueness for Credential Types
see: #6158
2017-05-04 16:18:56 -04:00
Wayne Witzel III
af35838aff Make kind read-only for PUT/PATCH, use isinstance in Host Manager, update field fasly check 2017-05-02 13:00:17 -04:00
Wayne Witzel III
a45d41b379 DynamicFilterQuerySet -> DynamicFilter 2017-05-01 12:55:42 -04:00
Wayne Witzel III
17e9b3057e Clean-up intiail commit for Host filter / DynamicInventory 2017-05-01 12:55:42 -04:00
Ryan Petrello
03460b311e treat tower as a reserved field name for custom CredentialTypes 2017-04-28 11:26:18 -04:00
AlanCoding
1169d19f8c Make Credential Type validator aware of "tower" var 2017-04-28 07:56:49 -04:00
Ryan Petrello
c0add33212 properly migrate vault credentials to the new credentialtype model 2017-04-25 15:03:16 -04:00
Chris Meyers
1f99a0df85 Merge pull request #6098 from chrismeyersfsu/fix-facts_query_performance
coarse json queries to use gin index
2017-04-25 10:58:09 -04:00
Chris Meyers
d69ae2cc92 coarse json queries to use gin index 2017-04-25 10:21:22 -04:00
Ryan Petrello
a36a53fe40 implement CredentialType env, file, and extra_vars injectors
see: #5877
2017-04-24 15:03:33 -04:00
Ryan Petrello
ba259e0ad4 Introduce a new CredentialTemplate model
Credentials now have a required CredentialType, which defines inputs
(i.e., username, password) and injectors (i.e., assign the username to
SOME_ENV_VARIABLE at job runtime)

This commit only implements the model changes necessary to support the
new inputs model, and includes code for the credential serializer that
allows backwards-compatible support for /api/v1/credentials/; tasks.py
still needs to be updated to actually respect CredentialType injectors.

This change *will* break the UI for credentials (because it needs to be
updated to use the new v2 endpoint).

see: #5877
see: #5876
see: #5805
2017-04-21 15:42:26 -04:00
Chris Meyers
5ff4966526 add json a=null support and still support a="null"
related to #6016
2017-04-13 16:26:35 -04:00
Chris Meyers
040f9dd545 support > 2 sequential and, also or
* Fixed a bug in the fact search language parser where it would not loop
over all the <and, or> operations. The result, we can support (a=b or
a=c or a=d) also support (a=b and b=b and c=b)
2017-04-13 13:36:38 -04:00
Chris Meyers
bd1f8b088f 400 on invalid host filter query instead of 500 2017-04-13 09:40:11 -04:00
Chris Meyers
a2b37aa7e6 add not logic to json search
* Also fix up single contains [] logic. Values with a single contains
should be wrapped in [] and not, like I thought before, \"\"
2017-04-12 15:11:36 -04:00
Chris Meyers
a4fe04cbfa handle unicode and types 2017-04-10 14:57:37 -04:00
Chris Meyers
5ce4c80821 support json/python types 2017-04-07 12:24:20 -04:00
Chris Meyers
02795e526c inherit from jsonbfield package not jsonfield
* jsonbfield supports json querying. jsonfield package is still a jsonb
postgres data type, but doesn't support jsonb style querying.
* add undo migration support to GIN index
2017-04-05 13:49:51 -04:00
Chris Meyers
f7fb541fe2 add facts recent endpoints
* Hang most recent listing of facts per-host off of /hosts/n/
2017-04-04 17:54:02 -04:00
Chris Meyers
f5d7d0bce5 add model fact recent
* Copy of the most recent system tracking fact for each module type.
Utimately, this allows us to GIN index the jsonb object to support
fact searching.
2017-04-04 16:32:30 -04:00
Chris Meyers
443f14ed85 flake8 is hard 2017-04-03 16:14:43 -04:00
Chris Meyers
80e89b1116 spelling is hard 2017-04-03 15:53:54 -04:00
Chris Meyers
6cbdb8d0e6 faster first time parse generator
* Generating the set of valid unicode characters is expensive in terms
of memory storage. Instead, we define the grammer by the negation of
allowed unicode characters. Much faster.
2017-04-03 15:32:21 -04:00
Chris Meyers
a8213661fd basic fact search grammar
* Establish a base grammar for handling json path specification and
value matching. With boolean logic support and parenthesis grouping
i.e. (a.b.c="value") and ((a.b="foo") or (a="bar"))
* generate Q() results for passing to Host.objects.filter()
* Hooked up via /api/v1/hosts?host_filter=...
* DynamicFilterField added to store host filter as string with grammar
parser attached as static methods for later use by DynamicInventory &
continued use by host_filter=...
2017-04-03 15:32:21 -04:00
AlanCoding
49faf212ef consolidate RBAC is_implicit_parent code 2017-03-24 09:25:24 -04:00
AlanCoding
169384ddbe Start RBAC unit testing system to test is_implicit_parent 2017-03-23 15:57:50 -04:00
AlanCoding
bb292f817b move check for implicit parent role into fields.py 2017-03-22 16:30:15 -04:00
Alan Rominger
a192077be4 Merge pull request #4025 from AlanCoding/text_type
Change JSONField to be a DB text type
2016-11-18 11:50:13 -05:00
Aaron Tan
9e4655419e Fix flake8 E302 errors. 2016-11-15 20:59:39 -05:00
AlanCoding
a1f2f64a09 change JSONField to be a DB text type 2016-11-15 13:57:10 -05:00
Chris Church
3eb6f55a80 Default JSONField to empty dict if field does not allow None. 2016-11-15 10:21:34 -05:00
Chris Church
8dc5e7725c Fix configure Tower in Tower to work with updated django-jsonfield. 2016-11-15 00:22:55 -05:00