Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login succeeds but later commands fail #731

Closed
tpetchel opened this issue May 10, 2016 · 7 comments
Closed

Login succeeds but later commands fail #731

tpetchel opened this issue May 10, 2016 · 7 comments
Labels
Component: CLI: compliance Type: Bug Feature not working as expected
Milestone

Comments

@tpetchel
Copy link
Contributor

Description

I am able to login to my Compliance server:

$ inspec compliance login https://chef-compliance.local --user john-smith --insecure --token ''
Your server supports --user and --password only
Successfully authenticated

But inspec compliance profiles fails like this:

$ inspec compliance profiles
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `new'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
    from /Users/thomaspetchel/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.0/lib/bundles/inspec-compliance/api.rb:31:in `profiles'
    from /Users/thomaspetchel/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.0/lib/bundles/inspec-compliance/cli.rb:63:in `profiles'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/thomaspetchel/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.0/bin/inspec:9:in `<top (required)>'
    from /Users/thomaspetchel/.chefdk/gem/ruby/2.1.0/bin/inspec:22:in `load'
    from /Users/thomaspetchel/.chefdk/gem/ruby/2.1.0/bin/inspec:22:in `<main>'

InSpec and Platform Version

$ inspec version
0.21.0

I am running Mac OS 10.11.3.

@tpetchel
Copy link
Contributor Author

Update

I tried logging in again, this time supplying my token:

$ inspec compliance login https://chef-compliance.local --user john-smith --insecure --token 'eyJhbGciOiJSUzI1N...qmWg'

Now this works:

$ inspec compliance profiles
Available profiles:
-------------------
 * base/apache
 * base/linux
 * base/mysql
 * base/postgres
 * base/ssh
 * base/windows
 * cis/cis-centos6-level1
 * cis/cis-centos6-level2
 * cis/cis-centos7-level1
 * cis/cis-centos7-level2
 * cis/cis-rhel6-level1
 * cis/cis-rhel6-level2
 * cis/cis-rhel7-level1
 * cis/cis-rhel7-level2
 * cis/cis-ubuntu12.04lts-level1
 * cis/cis-ubuntu12.04lts-level2
 * cis/cis-ubuntu14.04lts-level1
 * cis/cis-ubuntu14.04lts-level2

Apologies if you're supposed to always supply the token - the examples I saw used --token '' so I thought I was supposed to do exactly that (and perhaps a later CLI command would prompt me for my password or something to that effect.)

Regardless, perhaps we can make the error message clearer, either during login or while running subsequent commands.

@chris-rock chris-rock added the Type: Bug Feature not working as expected label May 11, 2016
@atul86244
Copy link

It doesn't work for me even when I pass the token:

$ inspec compliance  login https://compliance-server --token='fb3f7e81-d.............1c4942'  --user='admin' --insecure
$ inspec compliance  profiles
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `new'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
    from /Users/atul/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.6/lib/bundles/inspec-compliance/api.rb:31:in `profiles'
    from /Users/atul/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.6/lib/bundles/inspec-compliance/cli.rb:63:in `profiles'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/atul/.chefdk/gem/ruby/2.1.0/gems/inspec-0.21.6/bin/inspec:9:in `<top (required)>'
    from /opt/chefdk/embedded/bin/inspec:23:in `load'
    from /opt/chefdk/embedded/bin/inspec:23:in `<main>'

Inspec version:

$ inspec version
0.21.6

@chris-rock
Copy link
Contributor

@atul86244 Which Chef Compliance version are you using?

@cjohannsen81
Copy link

cjohannsen81 commented May 23, 2016

@atul86244 Hey Atul, just had the same issue. Mine was caused by a to short token as I just copied it from Safari... but it always ends copying with the first minus "-" sign!

@atul86244
Copy link

@chris-rock @cjohannsen81 I am using the latest version of Compliance (Version: 1.2.4). I have managed to fix this now. I think I was passing a wrong token but the inspec compliance login command always returns Successfully authenticated even if I pass a wrong token.

Look at this example below:

$ inspec compliance  login https://complianceserver --user='admin' --token='wrong_token' --insecure
Successfully authenticated
$ inspec version
0.22.0

Is this a known issue?

@cjohannsen81
Copy link

@atul86244 I think it´s known as I had the same discussion with @chris-rock today :)

@chris-rock chris-rock added this to the 1.0.0 milestone Jul 26, 2016
@jcii
Copy link

jcii commented Aug 10, 2016

Looking at this now...can authenticate with token, but then error from inspec compliance profiles

Compliance Server 1.3.1
Inspec 0.29

jcarter-mac:mchx-auth jcarter$ inspec compliance login https://qa-test.box.com --insecure --user admin --token 'eyJhbGciOiJSUzI1NiIsImtpZCI6Im9qeW1oeGFpZGR...iwidHlwIjoiSldUIn0'
Successfully authenticated
jcarter-mac:mchx-auth jcarter$ inspec compliance profiles
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `new'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
    from /Users/jcarter/.chefdk/gem/ruby/2.1.0/gems/inspec-0.29.0/lib/bundles/inspec-compliance/api.rb:31:in `profiles'
    from /Users/jcarter/.chefdk/gem/ruby/2.1.0/gems/inspec-0.29.0/lib/bundles/inspec-compliance/cli.rb:63:in `profiles'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/jcarter/.chefdk/gem/ruby/2.1.0/gems/inspec-0.29.0/bin/inspec:9:in `<top (required)>'
    from /opt/chefdk/embedded/bin/inspec:22:in `load'
    from /opt/chefdk/embedded/bin/inspec:22:in `<main>'
jcarter-mac:mchx-auth jcarter$ inspec version
0.29.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI: compliance Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

7 participants