riddl 0.99.213 → 0.99.214

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: 5c0d5de962676162c1b4fb7debeceb78037479fb
4
- data.tar.gz: c4b833642deeab806fcf9780141efffd73727e9f
3
+ metadata.gz: 327de3f2646080a6f91f901abbc02cdc60397c5c
4
+ data.tar.gz: 0c5ec7bf74dbfa4e0d3870db9c9086ebfda91a5d
5
5
  SHA512:
6
- metadata.gz: 69a511bfdfc3e5a3c88622317de6c3ca427a8efa59214b4199a847360c5a08bdbd38c11c281b1d5648f4de3f1e469fea77b07cb267b26fe9cc8a0e69b7aa7d64
7
- data.tar.gz: a2e287977c39d79eb0d68e39d34b6ebdc3e00e1210572768af437b127cede94097ccfff76a5b99825db8e4cee4205ff8fa528c391ee369e0506f8dd218440e52
6
+ metadata.gz: 361ac4490ae77ed21010205b350e51c16ddfae03a3a09f6ae96ab2d92ebedac52db4eb325a6eedb47ee4bc1e0b5fd2864627195bb6dd7201bdc6a5be1c4fa325
7
+ data.tar.gz: fb85cecb2795fb1e50eb90caa03d4ac03a7ac9cb0c1accb02317d605e6ce3f5a0227f475007e25bd3bc1520011cc2823739d8c8f40cabd7f98377f9f8da95252
@@ -0,0 +1,7 @@
1
+ <description datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:doc="http://riddl.org/ns/documentation/1.0">
2
+
3
+ <resource>
4
+ <get pass="*"/>
5
+ </resource>
6
+
7
+ </description>
@@ -3,6 +3,68 @@ require File.expand_path(File.dirname(__FILE__) + '/oauth2-helper')
3
3
  module Riddl
4
4
  module Utils
5
5
  module OAuth2
6
+
7
+ module UnivieBearer
8
+ def self::implementation(client_id, client_secret, access_tokens)
9
+ unless access_tokens.is_a?(Riddl::Utils::OAuth2::Helper::Tokens) client_id.is_a?(String) && client_secret.is_a?(String)
10
+ raise "client_id, client_secret or token storage not available."
11
+ end
12
+ Proc.new do
13
+ run CheckAuth, client_id, client_secret, access_tokens if get
14
+ end
15
+ end
16
+
17
+ class CheckAuth < Riddl::Implementation
18
+ def response
19
+ client_id = @a[0]
20
+ client_secret = @a[1]
21
+ access_tokens = @a[2]
22
+ if @h['AUTHORIZATION']
23
+ token = @h['AUTHORIZATION'].sub(/^Bearer /, '')
24
+
25
+ data, _, signature = token.rpartition '.'
26
+ expected_sign = Riddl::Utils::OAuth2::Helper::sign(client_id + ':' + client_secret, data)
27
+
28
+ if !access_tokens.key? token
29
+ @status = 403
30
+ return Riddl::Parameter::Complex.new('data', 'application/json', {
31
+ :error => 'Unknown token'
32
+ }.to_json)
33
+ elsif signature != expected_sign
34
+ @status = 403
35
+ return Riddl::Parameter::Complex.new('data', 'application/json', {
36
+ :error => 'Invalid token, you bad boy'
37
+ }.to_json)
38
+ end
39
+
40
+ header_claims, payload_claims = data.split('.').map { |v| Base64::urlsafe_decode64 v }
41
+ payload_claims = JSON::parse payload_claims
42
+
43
+ if header_claims != Riddl::Utils::OAuth2::Helper::header
44
+ @status = 401
45
+ return Riddl::Parameter::Complex.new('data', 'application/json', {
46
+ :error => 'Invalid header claims'
47
+ }.to_json)
48
+ elsif payload_claims['exp'] <= Time.now.to_i
49
+ @status = 403
50
+ return Riddl::Parameter::Complex.new('data', 'application/json', {
51
+ :error => 'Expired token'
52
+ }.to_json)
53
+ elsif !payload_claims['aud'].split(',').map(&:strip).include? client_id
54
+ # XXX: ein token für mehrere clients gültig? lookup?
55
+ @status = 403
56
+ return Riddl::Parameter::Complex.new('data', 'application/json', {
57
+ :error => 'Token is not valid for this application'
58
+ }.to_json)
59
+ end
60
+
61
+ @headers << Riddl::Header.new('AUTHORIZATION_BEARER', access_tokens[token])
62
+ end
63
+
64
+ @p
65
+ end
66
+ end
67
+ end
6
68
 
7
69
  module UnivieApp
8
70
  def self::implementation(client_id, client_secret, access_tokens, refresh_tokens)
@@ -0,0 +1,7 @@
1
+ <description datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:doc="http://riddl.org/ns/documentation/1.0">
2
+
3
+ <resource>
4
+ <get pass="*"/>
5
+ </resource>
6
+
7
+ </description>
data/riddl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.213"
3
+ s.version = "0.99.214"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.213
4
+ version: 0.99.214
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen 'eTM' Mangler
@@ -401,6 +401,7 @@ files:
401
401
  - lib/ruby/riddl/ns/common-patterns/notifications-consumer/1.0/consumer.xml
402
402
  - lib/ruby/riddl/ns/common-patterns/notifications-producer/1.0/producer.xml
403
403
  - lib/ruby/riddl/ns/common-patterns/oauth2-univie-app/1.0/app.xml
404
+ - lib/ruby/riddl/ns/common-patterns/oauth2-univie-app/1.0/bearer.xml
404
405
  - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.schema.schema
405
406
  - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.schema.xsl
406
407
  - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.xml
@@ -434,7 +435,7 @@ files:
434
435
  - lib/ruby/riddl/utils/fileserve.rb
435
436
  - lib/ruby/riddl/utils/notifications_producer.rb
436
437
  - lib/ruby/riddl/utils/oauth2-helper.rb
437
- - lib/ruby/riddl/utils/oauth2-univie-app.rb
438
+ - lib/ruby/riddl/utils/oauth2-univie.rb
438
439
  - lib/ruby/riddl/utils/properties.rb
439
440
  - lib/ruby/riddl/utils/turtle.rb
440
441
  - lib/ruby/riddl/utils/xmlserve.rb
@@ -457,6 +458,7 @@ files:
457
458
  - ns/common-patterns/notifications-consumer/1.0/consumer.xml
458
459
  - ns/common-patterns/notifications-producer/1.0/producer.xml
459
460
  - ns/common-patterns/oauth2-univie-app/1.0/app.xml
461
+ - ns/common-patterns/oauth2-univie-app/1.0/bearer.xml
460
462
  - ns/common-patterns/properties/1.0/properties.schema.schema
461
463
  - ns/common-patterns/properties/1.0/properties.schema.xsl
462
464
  - ns/common-patterns/properties/1.0/properties.xml