omniauth-usosumk 0.1.1 → 0.2.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: a492b9a34d0cbe980817db9f6ed39cd76ec231c32e322324609fdae286b4110c
4
- data.tar.gz: eea0045d58ae33f9eadc98107e7165a38252e406bc6efee94adcaf4c17173add
3
+ metadata.gz: 8188df14878e11e99f173b3061d0c506c46710fec6f167b58121a0ab11efc22a
4
+ data.tar.gz: 0d7c9b377a91e119da6ed0e29a07b3f3ee5a8efcc0ace9594512ac5654c6e9ee
5
5
  SHA512:
6
- metadata.gz: 8b044368afec9dec4b8b4a5a5da6624ca9bfdc32e60ebaf52ff114ed72fe3cbfd906114029a9eb608b4b441c40446df46921c455d3b3003cf63b388a3f52cd53
7
- data.tar.gz: e9c6102a1bc53a35e416446e7ffbf65a5c2e014a30ba418dd6c75751acd77084f79fd3793df070818dfee41e906540c1a53816cc2bcb0a16d67c91efdb691e14
6
+ metadata.gz: 8e284d37f47badf3d10b03f42100b75c7d30d6f5c08c4a705153114a3fd75badd5b9c60933a8d65239b7d4362308e09b554cc63604f2b3e4e8d5a1750c748b24
7
+ data.tar.gz: b912738b17a9620e7f76cde2d1e09c2a735dc8705d667a9cc3ac7049637c395f7744cc58a85553706eff318524269c6f13257d8945143d25f8c46a6244676ec2
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 mikolajczu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,28 +1,59 @@
1
- # Omniauth::Usosumk
2
- Short description and motivation.
1
+ # omniauth-usosumk
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ OmniAuth OAuth 1.0a strategy for authenticating against the USOS API at Nicolaus Copernicus University in Toruń (`usosapps.umk.pl`).
6
4
 
7
5
  ## Installation
8
- Add this line to your application's Gemfile:
6
+
7
+ Add to your application's `Gemfile`:
9
8
 
10
9
  ```ruby
11
10
  gem "omniauth-usosumk"
12
11
  ```
13
12
 
14
- And then execute:
13
+ Then:
14
+
15
15
  ```bash
16
- $ bundle
16
+ bundle install
17
17
  ```
18
18
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install omniauth-usosumk
19
+ ## Usage
20
+
21
+ Register your application with the USOS UMK administrators to obtain a `consumer_key` and `consumer_secret`. When registering, set the callback URL to `/oauth/callback` (or whatever you configure below).
22
+
23
+ Add the strategy to your OmniAuth middleware. In a Rails app, `config/initializers/omniauth.rb`:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :usosumk, ENV["USOSUMK_CONSUMER_KEY"], ENV["USOSUMK_CONSUMER_SECRET"]
28
+ end
22
29
  ```
23
30
 
24
- ## Contributing
25
- Contribution directions go here.
31
+ Then send users to `/auth/usosumk` to start the OAuth flow. After the user authorizes, USOS redirects to your `callback_url` and OmniAuth populates `request.env["omniauth.auth"]` with:
32
+
33
+ ```ruby
34
+ {
35
+ "provider" => "usosumk",
36
+ "uid" => "12345",
37
+ "info" => {
38
+ "email" => "student@umk.pl",
39
+ "first_name" => "Jan",
40
+ "last_name" => "Kowalski"
41
+ },
42
+ "extra" => { "raw_info" => { ... } }
43
+ }
44
+ ```
45
+
46
+ ### Options
47
+
48
+ - `callback_url` — path or full URL USOS will redirect to after authorization. Defaults to `/oauth/callback`. Must match what you registered on the USOS side.
49
+
50
+ ## Development
51
+
52
+ ```bash
53
+ bundle install
54
+ bundle exec rspec
55
+ ```
26
56
 
27
57
  ## License
28
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
58
+
59
+ [MIT](MIT-LICENSE).
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
1
  require "bundler/setup"
2
-
3
2
  require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -1,35 +1,37 @@
1
- require 'omniauth-oauth'
2
- require 'json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Usosumk < OmniAuth::Strategies::OAuth
7
- option :name, 'usosumk'
8
- option :callback_url, "/oauth/callback"
9
-
10
- option :client_options, {site: "https://usosapps.umk.pl",
11
- request_token_url: "/services/oauth/request_token?scopes=email",
12
- authorize_url: "https://usosapps.umk.pl/services/oauth/authorize",
13
- access_token_url: "/services/oauth/access_token"}
14
-
15
- uid { raw_info["id"] }
16
-
17
- info do
18
- {
19
- :email => raw_info["email"],
20
- :first_name => raw_info["first_name"],
21
- :last_name => raw_info["last_name"],
22
- }
23
- end
24
-
25
- extra do
26
- skip_info? ? {} : { :raw_info => raw_info }
27
- end
28
-
29
- def raw_info
30
- @raw_info ||= JSON.load(access_token.get("/services/users/user?fields=id|first_name|last_name|email").body)
31
- end
32
-
33
- end
34
- end
35
- end
1
+ require 'omniauth'
2
+ require 'omniauth-oauth'
3
+ require 'json'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Usosumk < OmniAuth::Strategies::OAuth
8
+ option :name, 'usosumk'
9
+ option :callback_url, "/oauth/callback"
10
+
11
+ option :client_options, {
12
+ site: "https://usosapps.umk.pl",
13
+ request_token_url: "/services/oauth/request_token?scopes=email",
14
+ authorize_url: "https://usosapps.umk.pl/services/oauth/authorize",
15
+ access_token_url: "/services/oauth/access_token"
16
+ }
17
+
18
+ uid { raw_info["id"] }
19
+
20
+ info do
21
+ {
22
+ email: raw_info["email"],
23
+ first_name: raw_info["first_name"],
24
+ last_name: raw_info["last_name"]
25
+ }
26
+ end
27
+
28
+ extra do
29
+ skip_info? ? {} : { raw_info: raw_info }
30
+ end
31
+
32
+ def raw_info
33
+ @raw_info ||= JSON.parse(access_token.get("/services/users/user?fields=id|first_name|last_name|email").body)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
- module Omniauth
2
- module Usosumk
3
- VERSION = "0.1.1"
4
- end
5
- end
1
+ module Omniauth
2
+ module Usosumk
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -1,2 +1,2 @@
1
- require "omniauth-usosumk/version"
1
+ require "omniauth-usosumk/version"
2
2
  require 'omniauth/strategies/usosumk'
metadata CHANGED
@@ -1,47 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-usosumk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mikolajczu
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: rails
13
+ name: omniauth
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 7.0.4
18
+ version: '2.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">="
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 7.0.4
27
- description: Oauth strategy for Usos umk
25
+ version: '2.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.2'
40
+ description: OmniAuth strategy for authenticating against the USOS API at Nicolaus
41
+ Copernicus University in Toruń (usosapps.umk.pl).
28
42
  email:
29
43
  - mikeyczu@gmail.com
30
44
  executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - MIT-LICENSE
34
49
  - README.md
35
50
  - Rakefile
36
51
  - lib/omniauth-usosumk.rb
37
52
  - lib/omniauth-usosumk/version.rb
38
53
  - lib/omniauth/strategies/usosumk.rb
39
- homepage: https://github.com/mikolajczu/omniauth-usosumk.git
40
- licenses: []
54
+ homepage: https://github.com/mikolajczu/omniauth-usosumk
55
+ licenses:
56
+ - MIT
41
57
  metadata:
42
- homepage_uri: https://github.com/mikolajczu/omniauth-usosumk.git
43
- source_code_uri: https://github.com/mikolajczu/omniauth-usosumk.git
44
- post_install_message:
58
+ source_code_uri: https://github.com/mikolajczu/omniauth-usosumk
45
59
  rdoc_options: []
46
60
  require_paths:
47
61
  - lib
@@ -49,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
63
  requirements:
50
64
  - - ">="
51
65
  - !ruby/object:Gem::Version
52
- version: '0'
66
+ version: '3.0'
53
67
  required_rubygems_version: !ruby/object:Gem::Requirement
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
57
71
  version: '0'
58
72
  requirements: []
59
- rubygems_version: 3.3.26
60
- signing_key:
73
+ rubygems_version: 3.6.9
61
74
  specification_version: 4
62
- summary: summary
75
+ summary: OmniAuth OAuth 1.0a strategy for USOS UMK
63
76
  test_files: []