rack-webfinger 0.1.0 → 0.2.0
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 +27 -1
- data/lib/rack/webfinger/version.rb +1 -1
- data/lib/rack/webfinger.rb +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 541982ded51019906d304bcf762e749171accfb90858067087ab8e69959c1838
|
4
|
+
data.tar.gz: 54dfc926cdfa893418db8ad0a6d129035821c818079f41ea8ddebdebf8320ecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2aff15955cbe4281f4dd40baecd5603506b0ce05922030d2498526fcee28badd31eed7e266e3a0f067eb9c3495fa0460933147f9a3fb2f1ac1a9cde1bd2fb6
|
7
|
+
data.tar.gz: c77db30be160f31f1264c17c3fccc9c6406d84006fa252bac472b71668200c400043ff72724efe20bffb1789b0123966ef36ffd75e30924f80ac5a67dad1b73d
|
data/README.md
CHANGED
@@ -16,7 +16,33 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
|
19
|
+
In your `config.ru` add:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'rack/webfinger'
|
23
|
+
|
24
|
+
use Rack::Webfinger, provider
|
25
|
+
```
|
26
|
+
|
27
|
+
`provider` must be a callable (lambda, proc, class responding to `#
|
28
|
+
call`) that takes a resource name and an array of rel filters in.
|
29
|
+
You can choose to ignore the rel filters - filtering will be done for
|
30
|
+
you.
|
31
|
+
|
32
|
+
You need to return a Hash of this format:
|
33
|
+
|
34
|
+
```
|
35
|
+
{
|
36
|
+
aliases: ["list","of","aliases"],
|
37
|
+
links: [
|
38
|
+
{ "rel": "rel url", "type": "text/html", "href": "link" }
|
39
|
+
]
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
43
|
+
This will be simplified, with constants for common rel values, and
|
44
|
+
defaults available.
|
45
|
+
|
20
46
|
|
21
47
|
## Development
|
22
48
|
|
data/lib/rack/webfinger.rb
CHANGED
@@ -6,21 +6,25 @@ require_relative "webfinger/version"
|
|
6
6
|
|
7
7
|
module Rack
|
8
8
|
class Webfinger
|
9
|
-
def initialize(data_provider)
|
9
|
+
def initialize(app, data_provider)
|
10
|
+
@app = app
|
10
11
|
@data_provider = data_provider
|
11
12
|
end
|
12
13
|
|
13
|
-
def not_found = [404, { '
|
14
|
+
def not_found = [404, { 'content-type' => 'text/plain' }, ['Resource not found']]
|
14
15
|
|
15
16
|
def call(env)
|
16
17
|
request = Rack::Request.new(env)
|
17
18
|
|
18
|
-
|
19
|
+
if request.path != '/.well-known/webfinger'
|
20
|
+
return @app.call(env) if @app
|
21
|
+
return not_found
|
22
|
+
end
|
19
23
|
|
20
24
|
resource = request.params['resource']
|
21
25
|
|
22
26
|
if !resource
|
23
|
-
return [400, { '
|
27
|
+
return [400, { 'content-type' => 'text/plain' }, ['Missing resource parameter']]
|
24
28
|
end
|
25
29
|
|
26
30
|
# We need this because Rack's handling of the query string by default overwrites
|
@@ -41,7 +45,7 @@ module Rack
|
|
41
45
|
filtered_data = filter_by_rel(response_data, rel_params)
|
42
46
|
|
43
47
|
[200,
|
44
|
-
{ '
|
48
|
+
{ 'content-type' => 'application/jrd+json' },
|
45
49
|
[JSON.generate(filtered_data)]
|
46
50
|
]
|
47
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-webfinger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vidar Hokstad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-test
|