aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-30 16:10:38 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-30 16:10:38 +0200
commitbf6bb598c9f57794d756d4147d3a271386e1473a (patch)
treeb8a89a0d28fde6622c167ffcdf325c04447f6bb6
parentfd00c5098df78de4166745432c776d773c7c174b (diff)
downloadreclaim-oidc-bf6bb598c9f57794d756d4147d3a271386e1473a.tar.gz
reclaim-oidc-bf6bb598c9f57794d756d4147d3a271386e1473a.zip
0.0.5
-rw-r--r--lib/reclaim_oidc.rb38
-rw-r--r--reclaim-oidc.gemspec4
2 files changed, 22 insertions, 20 deletions
diff --git a/lib/reclaim_oidc.rb b/lib/reclaim_oidc.rb
index 2f5151b..c7ccaaf 100644
--- a/lib/reclaim_oidc.rb
+++ b/lib/reclaim_oidc.rb
@@ -1,14 +1,18 @@
1require 'net/http' 1require 'net/http'
2require 'json' 2require 'json'
3 3
4$VERSION_MAJOR = 0
5$VERSION_MINOR = 0
6$VERSION_MICRO = 5
7
4class ReclaimOidc 8class ReclaimOidc
5 def initialize(verbose=false, url='http://localhost:7776') 9 def initialize(verbose=false, url='http://localhost:7776')
6 @verbose = verbose 10 @verbose = verbose
7 @url = url 11 @url = url
8 @client_secret = get_client_secret() 12 @client_secret = get_client_secret()
9 end 13 end
10 def self.hello 14 def self.version
11 puts "Hello World!" 15 return "#{$VERSION_MAJOR}.#{$VERSION_MINOR}.#{$VERSION_MICRO}"
12 end 16 end
13 def parse_identities_from_http(body) 17 def parse_identities_from_http(body)
14 arr = JSON.parse(body) 18 arr = JSON.parse(body)
@@ -48,25 +52,18 @@ class ReclaimOidc
48 resp = http.post(uri.path, payload.to_json) 52 resp = http.post(uri.path, payload.to_json)
49 end 53 end
50 uri = URI(@url + "/namestore/#{name}") 54 uri = URI(@url + "/namestore/#{name}")
51 record = {'record_type' => "RECLAIM_OIDC_CLIENT", 55 records = {'record_name' => "@",
56 'data' => []}
57 records["data"] << {'record_type' => "RECLAIM_OIDC_CLIENT",
52 'value' => description, 58 'value' => description,
53 'record_name' => "@",
54 'expiration_time' => "1h", 59 'expiration_time' => "1h",
55 'flag' => 8} 60 'flag' => 8}
56 #resp = Net::HTTP.post(uri,record.to_json) 61 records["data"] << {'record_type' => "RECLAIM_OIDC_REDIRECT",
57 #req = Net::HTTP::Post.new(uri, record)
58 Net::HTTP.start(uri.host, uri.port) do |http|
59 resp = http.post(uri.path,record.to_json)
60 end
61 record = {'record_type' => "RECLAIM_OIDC_REDIRECT",
62 'value' => redirect_uri, 62 'value' => redirect_uri,
63 'record_name' => "@",
64 'expiration_time' => "1h", 63 'expiration_time' => "1h",
65 'flag' => 8} 64 'flag' => 8}
66 #req = Net::HTTP::Post.new(uri, record)
67 #resp = Net::HTTP.post(uri,record.to_json)
68 Net::HTTP.start(uri.host, uri.port) do |http| 65 Net::HTTP.start(uri.host, uri.port) do |http|
69 resp = http.post(uri.path,record.to_json) 66 resp = http.post(uri.path,records.to_json)
70 end 67 end
71 end 68 end
72 def delete_client(name) 69 def delete_client(name)
@@ -105,11 +102,16 @@ class ReclaimOidc
105 end 102 end
106 def parse_client_info(obj) 103 def parse_client_info(obj)
107 obj.each do |record| 104 obj.each do |record|
108 if (record['record_type'] == 'RECLAIM_OIDC_CLIENT') 105 if "@" != record["record_name"]
109 @description = record['value'] 106 next
110 end 107 end
111 if (record['record_type'] == 'RECLAIM_OIDC_REDIRECT') 108 record["data"].each do |data|
112 @redirect_uri = record['value'] 109 if (data['record_type'] == 'RECLAIM_OIDC_CLIENT')
110 @description = data['value']
111 end
112 if (data['record_type'] == 'RECLAIM_OIDC_REDIRECT')
113 @redirect_uri = data['value']
114 end
113 end 115 end
114 end 116 end
115 end 117 end
diff --git a/reclaim-oidc.gemspec b/reclaim-oidc.gemspec
index 0dfb0c7..db414f8 100644
--- a/reclaim-oidc.gemspec
+++ b/reclaim-oidc.gemspec
@@ -1,7 +1,7 @@
1Gem::Specification.new do |s| 1Gem::Specification.new do |s|
2 s.name = 'reclaim-oidc' 2 s.name = 'reclaim-oidc'
3 s.version = '0.0.4' 3 s.version = '0.0.5'
4 s.date = '2019-04-28' 4 s.date = '2019-04-30'
5 s.summary = "re:claimID OpenID Connect CLI" 5 s.summary = "re:claimID OpenID Connect CLI"
6 s.description = "Used to manage re:claimID OpenID Connect clients and OpenID Connect Provider configuration(s)" 6 s.description = "Used to manage re:claimID OpenID Connect clients and OpenID Connect Provider configuration(s)"
7 s.authors = ["Martin Schanzenbach"] 7 s.authors = ["Martin Schanzenbach"]