Verify Credentials.
()
| 50 | methods=['POST'], endpoint='verify_credentials') |
| 51 | @pga_login_required |
| 52 | def verify_credentials(): |
| 53 | """Verify Credentials.""" |
| 54 | msg = '' |
| 55 | data = json.loads(request.data) |
| 56 | |
| 57 | session_token = data['secret']['session_token'] if\ |
| 58 | 'session_token' in data['secret'] else None |
| 59 | |
| 60 | if 'aws' not in session: |
| 61 | session['aws'] = {} |
| 62 | |
| 63 | # Re-validate when this is the first call (no creds cached yet) or |
| 64 | # when the supplied creds differ from what's in session. |
| 65 | cached_secret = session['aws'].get('secret') |
| 66 | if cached_secret is None or cached_secret != data['secret']: |
| 67 | _rds = RDS( |
| 68 | access_key=data['secret']['access_key'], |
| 69 | secret_key=data['secret']['secret_access_key'], |
| 70 | session_token=session_token, |
| 71 | default_region=data['secret']['region']) |
| 72 | status, identity = _rds.validate_credentials() |
| 73 | if status: |
| 74 | session['aws']['secret'] = data['secret'] |
| 75 | msg = 'verified' |
| 76 | else: |
| 77 | msg = identity |
| 78 | else: |
| 79 | # Creds unchanged from a previous successful verify — already valid. |
| 80 | status = True |
| 81 | msg = 'verified' |
| 82 | |
| 83 | return make_json_response(success=status, info=sanitize_external_text(msg)) |
| 84 | |
| 85 | |
| 86 | @blueprint.route('/db_instances/', |
nothing calls this directly
no test coverage detected