Skip to content

Commit

Permalink
Issue and consume JWT tokens
Browse files Browse the repository at this point in the history
See cyberark/slosilo#10 for details.
  • Loading branch information
dividedmind committed Sep 4, 2017
1 parent 1b89df1 commit 3ef8629
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gem 'base32-crockford'
gem 'activesupport'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'random_password_generator', '= 1.0.0'
gem 'slosilo', '>=2.0.0'
gem 'slosilo', '~> 2.1', github: 'cyberark/slosilo', branch: 'feature/jwt'
gem 'listen'
gem 'gli', require: false

Expand All @@ -28,7 +28,7 @@ gem 'gli', require: false
gem 'ruby_dep', '= 1.3.1'

gem 'conjur-api', github: 'cyberark/api-ruby'
gem 'conjur-rack', github: 'conjurinc/conjur-rack'
gem 'conjur-rack', '~> 3.1', github: 'conjurinc/conjur-rack', branch: 'feature/jwt'
gem 'conjur-rack-heartbeat'
gem 'conjur-policy-parser', github: 'conjurinc/conjur-policy-parser', branch: 'possum'
gem 'rack-rewrite'
Expand Down
21 changes: 14 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ GIT

GIT
remote: https://github.com/conjurinc/conjur-rack.git
revision: c82a886e4e6e90df4c7de347b007cc8fe0b5c1b6
revision: 244f4127713758ce2efde2b14e045a241dc2e91f
branch: feature/jwt
specs:
conjur-rack (3.0.0.pre)
conjur-rack (3.1.0)
conjur-api (< 6)
rack (~> 1)
slosilo
slosilo (~> 2.1)

GIT
remote: https://github.com/cyberark/api-ruby.git
Expand All @@ -39,6 +40,13 @@ GIT
activesupport
rest-client

GIT
remote: https://github.com/cyberark/slosilo.git
revision: 4132657c09d089e9625a5c5237dc511fe8fb1548
branch: feature/jwt
specs:
slosilo (2.1.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -440,7 +448,6 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
slosilo (2.0.1)
spring (2.0.1)
activesupport (>= 4.2)
spring-commands-cucumber (1.0.1)
Expand Down Expand Up @@ -489,7 +496,7 @@ DEPENDENCIES
conjur-cli!
conjur-debify
conjur-policy-parser!
conjur-rack!
conjur-rack (~> 3.1)!
conjur-rack-heartbeat
cucumber
database_cleaner
Expand Down Expand Up @@ -519,12 +526,12 @@ DEPENDENCIES
sequel-postgres-schemata
sequel-rails
simplecov
slosilo (>= 2.0.0)
slosilo (~> 2.1)!
spring
spring-commands-cucumber
spring-commands-rspec
table_print
therubyracer

BUNDLED WITH
1.15.3
1.15.4
2 changes: 1 addition & 1 deletion app/controllers/concerns/token_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def signing_key
end

def sign_token role
signing_key.signed_token Role.username_from_roleid(role.id)
signing_key.issue_jwt sub: Role.username_from_roleid(role.id)
end

end
10 changes: 5 additions & 5 deletions spec/controllers/authenticate_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
RSpec::Matchers.define :have_valid_token_for do |login|
match do |response|
expect(response).to be_ok
token = JSON.parse response.body
expect(token['data']).to eq(login)
expect(token).to have_key('signature')
expect(token).to have_key('timestamp')
token = Slosilo::JWT.parse_json response.body
expect(token.claims['sub']).to eq(login)
expect(token.signature).to be
expect(token.claims).to have_key('iat')
end
end

Expand Down Expand Up @@ -71,4 +71,4 @@ def invoke
end
end
end
end
end

0 comments on commit 3ef8629

Please sign in to comment.