blockstack 0.5.3 → 0.5.4
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/README.md +31 -3
- data/lib/blockstack/version.rb +1 -1
- data/lib/blockstack.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02267b69cdddc84f00b4191a4f7e01d437899683
|
4
|
+
data.tar.gz: 8a6570ed5583f394aedee4651f428066eb07fe87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de6af8bb0904587a96085cf1df76f584c1ca2c043db6c9795e96dccd33f9e403dcda5f9e5d9b42e7b0e61576f97ada1bd7f128de1995f95769ac6b5c9ac3eebc
|
7
|
+
data.tar.gz: 2d57131387cb060c3a2dd4bf166e354021b72b052ec1192d05add01b87fa4e7495a3e98d9ecc938e57d893edc974bb7d9913006b7a541e6dbd253e4a55ee689b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Blockstack
|
1
|
+
# Blockstack Ruby
|
2
2
|
|
3
3
|
The Blockstack ruby library for identity and authentication
|
4
4
|
|
@@ -20,7 +20,35 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
The Blockstack Ruby gem can be used to enable authentication with Blockstack on ruby apps
|
24
|
+
where authentication needs to occur on the server.
|
25
|
+
|
26
|
+
Authentication requests are generated with the [blockstack-js](https://github.com/blockstack/blockstack.js) JavaScript library in the user's web browser.
|
27
|
+
|
28
|
+
Authentication responses from the user's Blockstack Portal will be sent to a callback URL
|
29
|
+
that you provide and are verified using this library on your server.
|
30
|
+
|
31
|
+
For an example of this process and library in action, see
|
32
|
+
the [OmniAuth Blockstack strategy](https://github.com/blockstack/omniauth-blockstack).
|
33
|
+
|
34
|
+
### To verify an auth response
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require "blockstack"
|
38
|
+
|
39
|
+
begin
|
40
|
+
auth_response = request.params['authResponse']
|
41
|
+
|
42
|
+
decoded_auth_response = ::Blockstack.verify_auth_response auth_response
|
43
|
+
|
44
|
+
# login succeeded
|
45
|
+
users_unique_id = decoded_auth_response['iss']
|
46
|
+
verified_username = decoded_auth_response['username'] # nil if not provided
|
47
|
+
profile = decoded_auth_response['profile']
|
48
|
+
rescue ::Blockstack::InvalidAuthResponse => error
|
49
|
+
# login failed
|
50
|
+
end
|
51
|
+
```
|
24
52
|
|
25
53
|
## Development
|
26
54
|
|
@@ -30,7 +58,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
58
|
|
31
59
|
## Contributing
|
32
60
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/blockstack/blockstack-ruby.
|
34
62
|
|
35
63
|
|
36
64
|
## License
|
data/lib/blockstack/version.rb
CHANGED
data/lib/blockstack.rb
CHANGED
@@ -94,6 +94,8 @@ module Blockstack
|
|
94
94
|
decentralized_id.split(':')[2]
|
95
95
|
end
|
96
96
|
|
97
|
+
protected
|
98
|
+
|
97
99
|
def self.public_keys_match_issuer?(decoded_token)
|
98
100
|
public_keys = decoded_token['publicKeys']
|
99
101
|
address_from_issuer = get_address_from_did(decoded_token['iss'])
|
@@ -120,8 +122,6 @@ module Blockstack
|
|
120
122
|
name_owning_address == address_from_issuer
|
121
123
|
end
|
122
124
|
|
123
|
-
protected
|
124
|
-
|
125
125
|
def self.faraday
|
126
126
|
connection = Faraday.new
|
127
127
|
connection.headers[:user_agent] = USER_AGENT
|