Sha256: 730fb072300ce37995544cd384020e013ea6923f296a369293c39ce9fbae6e2c
Contents?: true
Size: 877 Bytes
Versions: 2
Compression:
Stored size: 877 Bytes
Contents
# Use your own strategy AuthRails provides a base strategy that has two methods: `retrieve_resource` and `gen_token`. In your project, you may need to handle `refresh_token` in another approach instead of `allowed_token`. You can inherit base strategy and override those two methods to do your own strategy. ```rb # frozen_string_literal: true class YourOwnStrategy < AuthRails::Strategies::BaseStrategy class << self def retrieve_resource(payload:) # handle payload and retrieve the user using that payload end def gen_token(resource:, payload:, exp: nil, secret_key: nil, algorithm: nil, jti: nil) # handle how to generate refresh_token end end end ``` Next, add this class to the configuration. ```rb # frozen_string_literal: true AuthRails.configure do |config| config.jwt do |jwt| jwt.strategy = YourOwnStrategy end end ```
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
auth_rails-1.1.2 | docs/src/customization/custom-strategy.md |
auth_rails-1.1.1 | docs/src/customization/custom-strategy.md |