robust_server_socket 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/robust_server_socket.rb +0 -1
- data/lib/version.rb +1 -1
- metadata +1 -2
- data/README.md +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ab7c243900b7f5a64995876c99501a830670a1dfddc217c5f49ec2699fac503
|
|
4
|
+
data.tar.gz: 5c7552b5d17afae304cf186b5025b874a6a04b7afe80cd4c47092478a809689a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9faa202465b8c25c0ec07fee1a4ea9f18531488a1f6f6eb4717bb29e5424ddb8266912e1eaf7dda84c366ed276beede43b740eadb5fdde9a146f14b3b99b601b
|
|
7
|
+
data.tar.gz: 410d43f438f999b0474d939319c65647ecc617c7a3313be38d0b7eb567cc20bc64d3f766bdca60089131c55fbd868849f3ba1f1cddf04bb4623f51e50c813f1c
|
data/lib/robust_server_socket.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: robust_server_socket
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tee_zed
|
|
@@ -75,7 +75,6 @@ files:
|
|
|
75
75
|
- ".rspec"
|
|
76
76
|
- CODE_OF_CONDUCT.md
|
|
77
77
|
- LICENSE.txt
|
|
78
|
-
- README.md
|
|
79
78
|
- Rakefile
|
|
80
79
|
- lib/robust_server_socket.rb
|
|
81
80
|
- lib/robust_server_socket/client_token.rb
|
data/README.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# RobustServerSocket
|
|
2
|
-
|
|
3
|
-
Gem for in-service Authorization for using with RobustClientSocket
|
|
4
|
-
|
|
5
|
-
## Security
|
|
6
|
-
|
|
7
|
-
- RSA-2048 key pair is used for authorization.
|
|
8
|
-
- Authorized client names are stored in token and config
|
|
9
|
-
- Token is staleable
|
|
10
|
-
- Token if one-time use only
|
|
11
|
-
- Blacklist for tokens in redis
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
'config/initializers/robust_server_socket.rb'
|
|
16
|
-
|
|
17
|
-
```ruby
|
|
18
|
-
RobustServerSocket.configure do |c|
|
|
19
|
-
c.private_key = '-----PRIVATE KEY-----[...]' # private key of the service, from pair of keys by RobustServerSocket
|
|
20
|
-
c.token_expiration_time = 10.minutes # time in seconds for token expiration
|
|
21
|
-
c.allowed_services = %w(core) # list of services allowed to use this service, must be same as service name in keychain in RobustClientSocket
|
|
22
|
-
# so if we have
|
|
23
|
-
# RobustClientSocket.configure do |c|
|
|
24
|
-
# c.keychain = {
|
|
25
|
-
# core: { <<< service name
|
|
26
|
-
# base_uri: 'https://core.payrent.com',
|
|
27
|
-
# public_key: '-----BEGIN PUBLIC KEY-----[...]'
|
|
28
|
-
# },
|
|
29
|
-
# we should add 'core' to allowed_services
|
|
30
|
-
c.redis_url = 'redis://localhost:6379' # redis url for storing tokens
|
|
31
|
-
c.redis_pass = 'password' # redis password
|
|
32
|
-
|
|
33
|
-
# Optional: Rate Limiting (disabled by default)
|
|
34
|
-
c.rate_limit_enabled = true # enable rate limiting per client
|
|
35
|
-
c.rate_limit_max_requests = 100 # maximum requests per window (default: 100)
|
|
36
|
-
c.rate_limit_window_seconds = 60 # time window in seconds (default: 60)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
RobustServerSocket.load!
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
and then
|
|
43
|
-
|
|
44
|
-
```ruby
|
|
45
|
-
token = RobustServerSocket::ClientToken.new(token) # token - is a Bearer from secure-token header
|
|
46
|
-
token.valid? #Boolean check if token is not expired and client is allowed to use this service, main authorization check
|
|
47
|
-
token.client #String name of the client
|
|
48
|
-
|
|
49
|
-
RobustServerSocket::ClientToken.validate!(token) # shortcut for token.valid? and raises specific errors
|
|
50
|
-
```
|
|
51
|
-
## Errors
|
|
52
|
-
|
|
53
|
-
`RobustServerSocket::ClientToken::UnauthorizedClient` - client is not allowed to use this service you should add it to allowed_services
|
|
54
|
-
`RobustServerSocket::ClientToken::UsedToken` - token is already used
|
|
55
|
-
`RobustServerSocket::ClientToken::StaleToken` - token is stale over the expiration time
|
|
56
|
-
`RobustServerSocket::ClientToken::InvalidToken` - token decryption failed
|
|
57
|
-
`RobustServerSocket::ClientToken::RateLimitExceeded` - client exceeded rate limit (only when rate limiting is enabled)
|
|
58
|
-
|
|
59
|
-
|