https://github.com/rnd-soft/simple_encryptor
Simple ecnryption/decryption facility for rails
https://github.com/rnd-soft/simple_encryptor
Last synced: 10 months ago
JSON representation
Simple ecnryption/decryption facility for rails
- Host: GitHub
- URL: https://github.com/rnd-soft/simple_encryptor
- Owner: RND-SOFT
- Created: 2016-09-27T16:41:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-06T08:54:14.000Z (almost 9 years ago)
- Last Synced: 2025-01-20T20:33:13.879Z (11 months ago)
- Language: Ruby
- Size: 22.5 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simple_encryptor
Simple ecnryption/decryption facility for secure rails servers interaction. One of the server is a Client and other is Server.
### Client
Client means a server which call API of the server. It has own **identifier** and **secret** shared with API server.
### Server
Server means a server whose API can be called by multiple client. Server must share **identifiers** and **secrets** with all clients. Identifier and Secret generation, distribution and maintaining is out of SimpleEncryptor responsibility.
## Configure your controller
```ruby
class ApplicationController < ActionController::Base
include SimpleEncryptor::Controller
simple_enc_server store: :get_from_secrets , encryptor: :encryptor
def get_from_secrets(identifier)
return Rails.application.secrets.clients['identifier']
end
end
```
## Options for simple_enc_server
### store
Store can be Symbol, Block or Class. Block is called with **identifier** argument:
```ruby
simple_enc_server store: ->(identifier){return "SECRET"}
```
Class must implement ```secret``` function with returns **secret** for passed **identifier**. In case of symbol this method of the controller called when **secret** must be obtained for identifier.
### encryptor
This is name of the SimpleEncryptor object attached for the controller. Default is ```encryptor```:
```ruby
class ApplicationController < ActionController::Base
include SimpleEncryptor::Controller
simple_enc_server store: :get_from_secrets , encryptor: :my_encryptor
def some_action
puts my_encryptor.secret("CLIENT_ID")
end
end
```