datawire / datawire-cli

Datawire Cloud tools and utilities
1 stars 0 forks source link

If you log out and back in, your service tokens are gone #28

Open janicedatawire opened 8 years ago

janicedatawire commented 8 years ago

If more than one user is using the same terminal/computer to use the cloud tools CLI, services created by a user are only available during the session in which they were created. This is true whether the user logs out or if another user logs in while the original user is still actively logged in.

Note: as of midweek last week services were accessible across multiple sessions - something changed that caused it stop working later in the week (discovered on Friday).

User jmk1 creates three services:

$ dwc status
Logged in as [BJSJ7HV3JD]jmk1@example.org:

Capabilities:
- dw:admin0: Organization administator
- dw:reqSvc0: Able to request service tokens
- dw:user0: User

Services defined:
- service1
- service2
- service3

Here's the datawire.json file:

{
    "orgID":"BJSJ7HV3JD",
    "orgs":{
        "BJSJ7HV3JD":{
            "email":"jmk1@example.org",
            "service_tokens":{
                "service1":"<token>",
                "service2":"<token>",
                "service3":"<token>"
            },
            "user_token":"<token>"
        },
        "H3PSFJ7NZ2":{
            "email":"jmk4@example.org",
            "user_token":"<token>"
        }
    }
}

User jmk2 logs in from the same terminal:

$ dwc status
Logged in as [BJSJ7HV3JD]jmk2@example.org:

Capabilities:
- dw:admin0: Organization administator
- dw:reqSvc0: Able to request service tokens
- dw:user0: User

No services defined

and datawire.json:

{
    "orgID":"BJSJ7HV3JD",
    "orgs":{
        "BJSJ7HV3JD":{
            "email":"jmk2@example.org",
            "user_token":"<token>"
        },
        "H3PSFJ7NZ2":{
            "email":"jmk4@example.org",
            "user_token":"<token>"
        }
    }
}

If I log back in as jmk1, I now get the following:

$ dwc status
Logged in as [BJSJ7HV3JD]jmk1@example.org:

Capabilities:
- dw:admin0: Organization administator
- dw:reqSvc0: Able to request service tokens
- dw:user0: User

No services defined

with this datawire.json:

{
    "orgID":"BJSJ7HV3JD",
    "orgs":{
        "BJSJ7HV3JD":{
            "email":"jmk1@example.org",
            "user_token":"<token>"
        },
        "H3PSFJ7NZ2":{
            "email":"jmk4@example.org",
            "user_token":"<token>"
        }
    }
}

And if I try to retrieve a token for one of those missing services I'm told I have no services:

$ dwc service-token service1
failure: You haven't created any services in this org!
kflynn commented 8 years ago

You don't need more than one user to show this. Just log out, then log back in as the same user.

In general, I'm not concerned with people sharing terminals – devs basically never do that ever (it's a security risk, but more to the point, devs are religious about customizations to their environments, so much so that e.g. if you ask Phil to drive my laptop for a minute, he'll hate it). OTOH logging out and back in will definitely happen.