micropub-server-rails 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12fe8b38f09c8a000d0786d8ffba9a534699c0d
|
4
|
+
data.tar.gz: 1abb0c60e179df042075f07d9ddab12824759410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 388fb7685ff270fef7e514b0c0da9739af1de5eeea7c62eb1ab64bd29125ada1e164f9067258c48863fc7383ab67c9113d45bdbcd8d3181c3922fb5fa35de309
|
7
|
+
data.tar.gz: 937316f298888fbeb396ccea9fc6125856957937bccad59f7d00c36685d32451a45067eb73f85e568d6b092f8f7053055cef8c07f3330c6c6b1a672a1eb1338f
|
@@ -1,3 +1,11 @@
|
|
1
|
+
require 'micropub'
|
2
|
+
|
3
|
+
Micropub.configure do |c|
|
4
|
+
c.token_endpoint = "https://tokens.indieauth.com/token"
|
5
|
+
c.me = "http://bookisworthy.com"
|
6
|
+
c.allowed_scopes = [:post]
|
7
|
+
end
|
8
|
+
|
1
9
|
module Micropub::Server::Rails
|
2
10
|
class Middleware
|
3
11
|
def initialize(app)
|
@@ -5,13 +13,46 @@ module Micropub::Server::Rails
|
|
5
13
|
end
|
6
14
|
|
7
15
|
def call(env)
|
16
|
+
@env = env
|
8
17
|
if env["PATH_INFO"] == "/micropub"
|
9
|
-
|
18
|
+
token = Micropub::Token.new(auth_token)
|
19
|
+
if token.valid?
|
20
|
+
response
|
21
|
+
else
|
22
|
+
error_response
|
23
|
+
end
|
10
24
|
else
|
11
25
|
@app.call env
|
12
26
|
end
|
13
27
|
end
|
14
28
|
|
29
|
+
def env
|
30
|
+
@env
|
31
|
+
end
|
32
|
+
|
33
|
+
def auth_token
|
34
|
+
@auth_token ||= begin
|
35
|
+
input = env["HTTP_AUTHORIZATION"] || params[:access_token] || ""
|
36
|
+
input.split("Bearer ").last
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def response
|
41
|
+
[201, headers, ["I am micropub."]]
|
42
|
+
end
|
43
|
+
|
44
|
+
def error_response
|
45
|
+
[401, {}, [""]]
|
46
|
+
end
|
47
|
+
|
48
|
+
def request
|
49
|
+
@request ||= Rack::Request.new(env)
|
50
|
+
end
|
51
|
+
|
52
|
+
def params
|
53
|
+
request.params
|
54
|
+
end
|
55
|
+
|
15
56
|
def headers
|
16
57
|
{
|
17
58
|
"Location" => "http://bookisworthy.com/posts/1",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micropub-server-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Becker
|
@@ -57,16 +57,16 @@ dependencies:
|
|
57
57
|
name: micropub
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 0.0.3
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 0.0.3
|
70
70
|
description: Micropub Railtie
|
71
71
|
email:
|
72
72
|
- veganstraightedge@gmail.com
|