omniauth-vis 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fff8038574bf91729b2f16a86e8ab9715838465182ec84d53bb52e99358eebf5
4
- data.tar.gz: 0d594fa3bb66c5eef23860466287b70fad945689b1659091ce96d1dd9009b173
3
+ metadata.gz: 2c033910cb1b4079859bd39ac8f335d4851fe71ba884d49e67b5c290954f9bae
4
+ data.tar.gz: e7ad31f822e75d60f2834818fa73a90f7340d21458827bb1abe4c68eaf0a1558
5
5
  SHA512:
6
- metadata.gz: ea3a60610a40dcf505c9640d5e3c954fe74a90efe1e78c35fdb9d80cd072c611664302a065285d0e4b1eeec802cba0d020a32354be98d7535563840d94fb7267
7
- data.tar.gz: 6db202573cb2234b42d626230d798226ca2b4729d6fda9a54d35a57481e7be21c0e147f315d98e5db36eb542ea169b0c42e2385b2d9e0a837447cf14e0b0d76e
6
+ metadata.gz: fd676cdec4deafc8ff4768e4277163689d9d76b1416a9610cdff112b80269fcc1af2dbb324b8ce04eaf6fd84763342738adc34ebdc6096e8b4656ac653f60502
7
+ data.tar.gz: 8c629c538a57de590710ed7f7faeb578fc5d951ba45aa22870da952fd76e9370322f2c348204f9c84534a23106336189cf463d526393ec41722b9daa84246dec
data/README.md CHANGED
@@ -53,17 +53,17 @@ end
53
53
 
54
54
  ```
55
55
  require "vis/api"
56
- @vis_api = Vis::Api.new
57
- @vis_service.get("api_path")
58
- @vis_service.post("api_path", data)
56
+ @vis_api = Vis::Api.new(client_id: "xx", client_secret: "xx", server_url: "https://identity.dhamma.org")
57
+ @vis_api.get("api_path")
58
+ @vis_api.post("api_path", data)
59
59
  ```
60
60
 
61
- Documentation about available api can be found at [https://identity.server.dhamma.org/doc](https://identity.server.dhamma.org/doc)
61
+ Documentation about available api can be found at [https://test.identity.dhamma.org/doc](https://test.identity.dhamma.org/doc)
62
62
 
63
63
  Example
64
64
 
65
65
  ```
66
- Vis::Api.new.post("/api/v1/users", {
66
+ @vis_api.post("/api/v1/users", {
67
67
  email: "email@test.com",
68
68
  username: "test",
69
69
  encrypted_password: "xxxxxxxxxx"
@@ -8,18 +8,18 @@ module OmniAuth
8
8
  option :name, :vis
9
9
 
10
10
  option :client_options,
11
- site: Rails.application.config.vis['server_url'],
12
11
  authorize_path: '/oauth/authorize'
13
12
 
14
13
  option :scope, 'default'
15
14
 
16
- def on_path?(path)
17
- current_path.squeeze('/').casecmp(path.squeeze('/')).zero?
18
- end
15
+ option :server_url, "https://identity.dhamma.org"
19
16
 
20
17
  def setup_phase
18
+ # configure Oauth2 client_options.site from a custom server_url option
19
+ options.client_options.site = options.server_url
20
+
21
21
  # Authorize all params to be passed to VIS
22
- request.env['omniauth.strategy'].options[:authorize_params] = request.params.to_h
22
+ options.authorize_params = request.params.to_h
23
23
  end
24
24
 
25
25
  uid do
@@ -30,6 +30,11 @@ module OmniAuth
30
30
  raw_info
31
31
  end
32
32
 
33
+ # Fix strange bugs with urls containing double / like dhamma.org//oauth/callback
34
+ def on_path?(path)
35
+ current_path.squeeze('/').casecmp(path.squeeze('/')).zero?
36
+ end
37
+
33
38
  # to fix always getting invalid_grant error
34
39
  # see https://github.com/omniauth/omniauth-oauth2/issues/81#issuecomment-231442739
35
40
  def callback_url
data/lib/vis/api.rb CHANGED
@@ -2,10 +2,10 @@
2
2
  # gets tokens so we can use the VIS API
3
3
  module Vis
4
4
  class Api
5
- def initialize
6
- @client_id = Rails.application.config.vis["app_id"]
7
- @client_secret = Rails.application.config.vis["app_secret"]
8
- @vis_app_url = Rails.application.config.vis["app_url"]
5
+ def initialize(server_url: "https://identity.dhamma.org", client_id:, client_secret:)
6
+ @client_id = client_id
7
+ @client_secret = client_secret
8
+ @vis_app_url = server_url
9
9
  @use_ssl = !Rails.env.development?
10
10
  end
11
11
 
@@ -30,10 +30,8 @@ module Vis
30
30
  end
31
31
 
32
32
  private def token_post
33
- # uri = URI.parse("#{@vis_app_url})
34
33
  http_client, uri = http_client_and_uri "/oauth/token"
35
34
  request = Net::HTTP::Post.new(uri.request_uri)
36
- # request.set_form_data({ "client_id" => @client_id, "client_secret" => @client_secret,
37
35
  request.set_form_data({ "client_id" => @client_id, "client_secret" => @client_secret,
38
36
  "grant_type" => "client_credentials" })
39
37
  http_client.request(request)
data/omniauth-vis.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'omniauth-vis'
5
- gem.version = '0.0.8'
5
+ gem.version = '0.1.0'
6
6
  # gem.license = 'MIT'
7
7
  gem.summary = 'Helper to connect to Vipassna Identity Server'
8
8
  gem.description = 'This allows you to connect to Vipassana identity server with your ruby app'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-vis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dhamma workers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-04 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2