
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
This gem generates, stores, and helps you retrieve short-lived tokens with payloads. It is intended to be part of a capability link system, which allows users to perform actions without explicitly logging in.
Add this line to your application's Gemfile:
gem 'capability_tokens'
And then execute:
$ bundle
Then, install the migrations:
$ rake capability_tokens:install:migrations
And you're set! If you need to put the table this engine creates in a schema, create an initializer:
# config/initializers/capability_tokens.rb
CapabilityTokens.configure do |c|
c.schema_name = 'my_stuff'
end
Generate a new token:
requester = 'customer-service'
payload = { account_id: 1, action: 'login' }
cap_token = CapabilityTokens.generate(payload, requester, Time.now + 72.hours)
cap_token.token # => "82264468-6d50-454f-a257-007a89afa18b"
Disseminate the token as you see fit; e.g., in a link, like
http://yourapp.com/do_it/82264468-6d50-454f-a257-007a89afa18b
.
When a user follows that link, your controller might do:
begin
token = CapabilityTokens.retrieve(params[:token])
login_user!(token.payload[:account_id])
rescue CapabilityTokens::ExpiredToken
raise "Too late!"
rescue CapabilityTokens::InvalidToken
raise "Hacker!"
end
Note that CapabilityTokens::retrieve
will always raise an exception if the
retrieved token is either nonexistant or expired. You can rescue
CapabilityTokens::BadToken
to catch all errors.
FYI, "requester" is required as a very basic audit trail. If your needs are more complex, please open an issue and I'll investigate how to accomodate.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that capability_tokens demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.