authz_jurnal_client 0.0.3 → 0.0.5

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
  SHA256:
3
- metadata.gz: 8629db96453f7a2bcb57a10cc33e24225dc8d2c64887a73d1858f8f29c9d7e07
4
- data.tar.gz: c3d079a6784968c0353a3cc379f98755228e72b2f8557e16685ee487f9f1cb58
3
+ metadata.gz: d451a03c29d40d2db74d2e4ecb7a3af61869f0851603f588ab17fe7f7ff79c0f
4
+ data.tar.gz: 196c69edecba8d9151f1040b3d99d5501a29bacae2758e305aea4e0c78881e06
5
5
  SHA512:
6
- metadata.gz: 315f869e05b9640414729c70380fd582977def884d9cbb3072e93e17f280c376643ba72f65781b2808f0c82b4c20e51f2170f59abbfeef8a2b311abd727594d2
7
- data.tar.gz: d01429920786ab9e8f54e8ebc4858df688c813789b9ca641db696534dae0fdd39d37df96a67a71339bd696a9301d7de5bc3767260371b7c0dfa4fcbc5cc22662
6
+ metadata.gz: 03dc07308fdd976ca844f90790ff12bd1259d26db55b048206d4aa85b75aefa9d3f63fc919afd9e491630fdb2bdc60db56b6230de6fa54540d6f4ef695a6401d
7
+ data.tar.gz: 034cdd2ba58fe841bf15e21b8a024e79f700e686d7824120e5622ac60b39283a50337a1fa6be8e3dcade4180c09d932275a8d6ec1a77102d66a7bdda498c588c
data/.byebug_history ADDED
@@ -0,0 +1,11 @@
1
+ continue
2
+ d.to_json
3
+ d
4
+ continue
5
+ JSON.parse( j, object_class: OpenStruct).data.roles
6
+ j
7
+ continue
8
+ JSON.parse( j, object_class: OpenStruct).data.roles
9
+ j
10
+ continue
11
+ roles = AuthzJurnalClient::UserRoles.call(1, 1)
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,9 @@
1
+ example_id | status | run_time |
2
+ ----------------------------------------- | ------ | --------------- |
3
+ ./spec/authz_jurnal_client_spec.rb[1:1:1] | passed | 0.0031 seconds |
4
+ ./spec/authz_jurnal_client_spec.rb[1:2:1] | passed | 0.01582 seconds |
5
+ ./spec/authz_jurnal_client_spec.rb[1:2:2] | passed | 0.00067 seconds |
6
+ ./spec/authz_jurnal_client_spec.rb[1:3:1] | passed | 0.00443 seconds |
7
+ ./spec/authz_jurnal_client_spec.rb[1:3:2] | passed | 0.00199 seconds |
8
+ ./spec/authz_jurnal_client_spec.rb[1:4:1] | passed | 0.00143 seconds |
9
+ ./spec/authz_jurnal_client_spec.rb[1:4:2] | passed | 0.00153 seconds |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authz_jurnal_client (0.0.1)
4
+ authz_jurnal_client (0.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -0,0 +1,54 @@
1
+ # AuthzJurnalClient
2
+
3
+ AuthzJurnalClient allows you to access the user roles API directly. It also provides the advantage of managing the caching
4
+
5
+
6
+ ## Installation
7
+
8
+
9
+
10
+ Install the gem thusly in the gemfile
11
+
12
+ ``` markdown
13
+ gem 'authz_jurnal_client' or gem install authz_jurnal_client
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ``` Ruby
22
+ Default :
23
+ AuthzJurnalClient::UserRoles.config(authorization: "Basic ApiToken")
24
+ roles = AuthzJurnalClient::UserRoles.call(uid, cid)
25
+ puts roles
26
+
27
+ Customize :
28
+ AuthzJurnalClient::UserRoles.config(redis: "redis://localhost:6379", domain: 'http://mydomain.com', expiry: 3600, authorization: "Basic ApiToken")
29
+ roles = AuthzJurnalClient::UserRoles.call(uid, cid)
30
+ puts roles
31
+ ```
32
+
33
+ The response is a json parsed Openstruct
34
+
35
+ See tests for more details.
36
+
37
+
38
+
39
+ ### For hacking on the GEM
40
+
41
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/authz_jurnal_client`. To experiment with that code, run `bin/console` for an interactive prompt.
42
+
43
+
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem into your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/authz_jurnal_client.
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AuthzJurnalClient
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.5"
5
5
  end
@@ -2,6 +2,7 @@ require "ostruct"
2
2
  require "json"
3
3
  require "faraday"
4
4
  require "redis"
5
+ require 'byebug'
5
6
 
6
7
  require_relative "authz_jurnal_client/version"
7
8
 
@@ -10,16 +11,14 @@ module AuthzJurnalClient
10
11
 
11
12
  class UserRoles
12
13
  class << self
13
- attr_accessor :redis, :domain, :token, :expiry
14
+ attr_accessor :redis, :domain, :authorization, :expiry
14
15
  def config(opts = {})
15
- @redis = if opts[:redis].is_a? Hash
16
- Redis.new(opts[:redis])
17
- else
18
- opts[:redis]
19
- end
20
- @domain = opts[:domain]
21
- @headers = {"Authorization" => "Basic #{token}"}
22
- @expiry = opts[:expiry] || 3600 * 5
16
+ @authorization = opts[:authorization]
17
+ @headers = {"Authorization" => @authorization}
18
+ @domain = opts[:domain] || 'http://localhost:3000'
19
+ redis_path = opts[:redis] || 'redis://localhost:6379'
20
+ @redis = Redis.new(url: redis_path)
21
+ @expiry = opts[:expiry] || 3600
23
22
  end
24
23
 
25
24
  def call(id, cid)
@@ -47,12 +46,12 @@ module AuthzJurnalClient
47
46
  end
48
47
 
49
48
  def make_key(id, cid)
50
- "manage_role:#{id}-#{cid}"
49
+ "manage_roles:#{id}-#{cid}"
51
50
  end
52
51
 
53
52
  def get_roles(j)
54
- res = JSON.parse(j)
55
- res['data']['roles'] if res['data'] && res['data']['roles']
53
+ data = eval(j)
54
+ JSON.parse( data.to_json, object_class: OpenStruct).data.roles
56
55
  end
57
56
  end
58
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authz_jurnal_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alam Topani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-02-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -17,12 +17,17 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".byebug_history"
21
+ - ".rspec"
22
+ - ".rspec_status"
20
23
  - Gemfile
21
24
  - Gemfile.lock
22
25
  - README.md
23
26
  - Rakefile
24
27
  - authz_jurnal_client-0.0.1.gem
25
28
  - authz_jurnal_client-0.0.2.gem
29
+ - authz_jurnal_client-0.0.3.gem
30
+ - authz_jurnal_client-0.0.4.gem
26
31
  - lib/authz_jurnal_client.rb
27
32
  - lib/authz_jurnal_client/version.rb
28
33
  - lib/sig/authz_jurnal_client.rbs