diff options
author | Martin <mschanzenbach@posteo.de> | 2019-08-21 13:45:31 +0000 |
---|---|---|
committer | Martin <mschanzenbach@posteo.de> | 2019-08-21 13:45:31 +0000 |
commit | 0c494be7bd33625523327309ea4c251a92d54e3c (patch) | |
tree | 5da35a8de2000088ca46395ba8108ea34ff2c45c | |
parent | c3a02192335518cf36fda1c8fe96871f02efac6e (diff) | |
parent | 0e475c526c942c77ef34acd535ff7cbf173cadca (diff) | |
download | reclaim-oidc-0c494be7bd33625523327309ea4c251a92d54e3c.tar.gz reclaim-oidc-0c494be7bd33625523327309ea4c251a92d54e3c.zip |
Merge branch 'master' into 'master'
added error handling for unknown commands + REST service not running
See merge request reclaimid/reclaim-oidc!2
-rwxr-xr-x | bin/reclaim-oidc | 10 | ||||
-rw-r--r-- | lib/reclaim_oidc.rb | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/bin/reclaim-oidc b/bin/reclaim-oidc index 749c7e9..878f43f 100755 --- a/bin/reclaim-oidc +++ b/bin/reclaim-oidc | |||
@@ -89,13 +89,13 @@ class OptParser | |||
89 | self.verbose = v | 89 | self.verbose = v |
90 | end | 90 | end |
91 | end | 91 | end |
92 | 92 | ||
93 | def jwt_secret_option(parser) | 93 | def jwt_secret_option(parser) |
94 | parser.on("-j", "--jwt-secret [JWT-SECRET]", "Set JWT secret") do |v| | 94 | parser.on("-j", "--jwt-secret [JWT-SECRET]", "Set JWT secret") do |v| |
95 | self.jwt_secret = v | 95 | self.jwt_secret = v |
96 | end | 96 | end |
97 | end | 97 | end |
98 | end | 98 | end |
99 | 99 | ||
100 | # | 100 | # |
101 | # Return a structure describing the options. | 101 | # Return a structure describing the options. |
@@ -107,7 +107,11 @@ class OptParser | |||
107 | @options = ScriptOptions.new | 107 | @options = ScriptOptions.new |
108 | @args = OptionParser.new do |parser| | 108 | @args = OptionParser.new do |parser| |
109 | @options.define_options(parser) | 109 | @options.define_options(parser) |
110 | parser.parse!(args) | 110 | begin |
111 | parser.parse!(args) | ||
112 | rescue OptionParser::InvalidOption => e | ||
113 | puts "ERROR: Invalid option" | ||
114 | end | ||
111 | end | 115 | end |
112 | @options | 116 | @options |
113 | end | 117 | end |
diff --git a/lib/reclaim_oidc.rb b/lib/reclaim_oidc.rb index fa91c05..4c06936 100644 --- a/lib/reclaim_oidc.rb +++ b/lib/reclaim_oidc.rb | |||
@@ -26,8 +26,13 @@ class ReclaimOidc | |||
26 | 26 | ||
27 | def get_client_secret | 27 | def get_client_secret |
28 | uri = URI(@url + '/config/reclaim-rest-plugin') | 28 | uri = URI(@url + '/config/reclaim-rest-plugin') |
29 | resp = JSON.parse Net::HTTP.get(uri) | 29 | begin |
30 | return resp["OIDC_CLIENT_SECRET"] | 30 | resp = JSON.parse Net::HTTP.get(uri) |
31 | return resp["OIDC_CLIENT_SECRET"] | ||
32 | rescue Errno::ECONNREFUSED => e | ||
33 | puts "ERROR: REST service is not running" | ||
34 | exit | ||
35 | end | ||
31 | end | 36 | end |
32 | 37 | ||
33 | def get_clients | 38 | def get_clients |