AWS users not Confidant user! That explains everything.
I'm getting an encrypt error however trying to use that policy. Policy simulator shows it failing using all the same params on the correct key ARN.
Re attempting simulator with the use as admin succeeds. Not sure why as the policy looks correct.
# Error
2016-10-05 15:47:45,416:Â (parse)Â Response body:
b'{"__type":"AccessDeniedException","Message":"User: arn:aws:iam::007205783477:user/confidant-admin is not authorized to perform: kms:Encrypt on resource: arn:aws:kms:ap-southeast-2:1111111111111:key/df312c0c-9bdb-4148-a064-7c1888379d00"}'
Re attempting with Admin access on the user ,Indicates key decryption failure by Confidant:
Oct 5 23:00:40 development-confidant gunicorn[25490]: ClientError: An error occurred (InvalidCiphertextException) when calling the Decrypt operation:
Oct 5 23:00:40 development-confidant gunicorn[25490]: ERROR:root:Failed to decrypt authentication token.
Oct 5 23:00:40 development-confidant gunicorn[25490]: Traceback (most recent call last):
Oct 5 23:00:40 development-confidant gunicorn[25490]: File "/opt/confidant/confidant/authnz/__init__.py", line 176, in decorated
Oct 5 23:00:40 development-confidant gunicorn[25490]: kms_auth_data['token']
Oct 5 23:00:40 development-confidant gunicorn[25490]: File "/opt/confidant/confidant/keymanager.py", line 158, in decrypt_token
Oct 5 23:00:40 development-confidant gunicorn[25490]: raise TokenDecryptionError('Authentication error. General error.')
Oct 5 23:00:40 development-confidant gunicorn[25490]: TokenDecryptionError: Authentication error. General error.
Oct 5 23:00:40 development-confidant gunicorn[25490]: WARNING:root:Access denied for confidant-admin. Authentication Failed.
I did notice that Boto keeps vaguely referring to version 4 during debug output, I cant see any way to force a particular token version in Boto:
2016-10-05 16:00:40,593:Â (add_auth)Â Calculating signature using v4 auth.
2016-10-05 16:00:40,593:Â (add_auth)Â CanonicalRequest:
POST
/
content-type:application/x-amz-json-1.1
host:
kms.ap-southeast-2.amazonaws.comx-amz-date:20161005T230040Z
x-amz-target:TrentService.Encrypt
content-type;host;x-amz-date;x-amz-target
8ad562d2a314223cee12c40114ff52b16ce3123c3c5a946bec554f35b9542f57
2016-10-05 16:00:40,593:Â (add_auth)Â StringToSign:
AWS4-HMAC-SHA256
20161005T230040Z
20161005/ap-southeast-2/kms/aws4_request
# confidant-admin attached policy
{
   "Version": "2012-10-17",
   "Statement": [{
      "Action": [
         "kms:GenerateRandom"
      ],
      "Effect": "Allow",
      "Resource": "*"
   }, {
      "Action": [
         "kms:Encrypt"
      ],
      "Effect": "Allow",
      "Resource": [
         "arn:aws:kms:ap-southeast-2:1111111111:key/df312c0c-9bdb-4148-a064-7c1888379d00"
      ],
      "Condition": {
         "StringEquals": {
            "kms:EncryptionContext:to": "development-confidant",
            "kms:EncryptionContext:user_type": "user",
            "kms:EncryptionContext:from": "confidant-admin"
         },
         "Bool": {
            "aws:MultiFactorAuthPresent": "false"
         }
      }
   }, {
      "Action": [
         "kms:Encrypt"
      ],
      "Effect": "Allow",
      "Resource": [
         "arn:aws:kms:ap-southeast-2:111111111111:key/df312c0c-9bdb-4148-a064-7c1888379d00"
      ],
      "Condition": {
         "StringLike": {
            "kms:EncryptionContext:to": "*"
         },
         "StringEquals": {
            "kms:EncryptionContext:user_type": "user",
            "kms:EncryptionContext:from": "confidant-admin"
         },
         "Bool": {
            "aws:MultiFactorAuthPresent": "false"
         }
      }
   }]
}
I'm going to retry using the actual auth key rather then the USER_AUTH_KEY.