TomonoriSoejima / Tejun

notes related to working cases
5 stars 3 forks source link

How to test api key #51

Open TomonoriSoejima opened 3 years ago

TomonoriSoejima commented 3 years ago
POST /_security/api_key
{
  "name": "kibana_user",
  "expiration": "1d"
}

kibana_key=UEhadi1uWUJ0U3d3a3lCTFBsNUY6LXh4UjhpdTlSMHVFdnBILUdPanBuZw== super_key=aDNaby1uWUJ0U3d3a3lCTEtGSGk6SDZkVDQ3VTJURHFxQkFNNkU0SmZTdw==

[nami:api_key_test]$ http -b $url Content-type:"application/json" Authorization:"ApiKey $kibana_key"
{
    "error": {
        "reason": "action [cluster:monitor/health] is unauthorized for API key id [PHZv-nYBtSwwkyBLPl5F] of user [2434140000]",
        "root_cause": [
            {
                "reason": "action [cluster:monitor/health] is unauthorized for API key id [PHZv-nYBtSwwkyBLPl5F] of user [2434140000]",
                "type": "security_exception"
            }
        ],
        "type": "security_exception"
    },
    "status": 403
}

[nami:api_key_test]$ http -b $url Content-type:"application/json" Authorization:"ApiKey $super_key"
{
    "active_primary_shards": 150,
    "active_shards": 300,
    "active_shards_percent_as_number": 100.0,
    "cluster_name": "7660b48f29e746bbbc20dd74c80368d0",
    "delayed_unassigned_shards": 0,
    "initializing_shards": 0,
    "number_of_data_nodes": 4,
    "number_of_in_flight_fetch": 0,
    "number_of_nodes": 5,
    "number_of_pending_tasks": 0,
    "relocating_shards": 0,
    "status": "green",
    "task_max_waiting_in_queue_millis": 0,
    "timed_out": false,
    "unassigned_shards": 0
}

[nami:api_key_test]$