ICS-MU / pam_oauth2_device

PAM module OAuth2 Device flow
Apache License 2.0
31 stars 14 forks source link

JSON parse error when hitting enter to authenticate #16

Closed willfurnell closed 4 years ago

willfurnell commented 4 years ago

Hi,

This project is so cool! I'm trying it out and have got as far as connecting it up to an IdP, but after authorizing the device code and hitting enter, I get the following JSON parser exception:

Hit enter when you authenticate

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what():  [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - invalid literal; last read: '<'
Aborted

I'm testing with the following command:

pamtester -v pamtester root authenticate

My config.json is as follows:

 {
    "oauth": {
        "client": {
            "id": "ssh-device-access",
            "secret": "secret"
        },
        "scope": "openid profile",
        "device_endpoint": "https://iam.example.com/devicecode",
        "token_endpoint": "http://iam.example.com/token",
        "userinfo_endpoint": "https://iam.example.com/userinfo",
        "username_attribute": "preferred_username"
    },
    "qr": {
        "error_correction_level": 0
    },
    "users": {
        "my-email-address@example.com": [
            "root"
        ]
    }
}

Is this to do with the users section? Sorry I'm not clear exactly how I should format it. I'm assuming that it maps email -> user but is this not the case?

Thank you! :)

willfurnell commented 4 years ago

This was a silly error on my part - I got the return buffer printed from cURL and it turns out there was a 301 redirect going on, as I had http not https in the token endpoint field! (So the JSON parser was trying to parse HTML)