omniauth-zeuswpi 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +43 -0
- data/README.md +76 -0
- data/lib/omniauth/zeuswpi/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5eb66f8bc8167c32055a23ab48ef1cd21265373b5b56b92e3adafb5157fc722
|
4
|
+
data.tar.gz: a3412cc3633f7dc193ad2d35b1b67c28e56e9a3bb04c6aebf3bbd3483cd17f4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c71863ed4aac88099157671fae11f2362dd41557a763e97f8a402f01ee6dc107da62390cb5850b5279d95037e442a9a9b6788d091b68359ec81f7f49ce76a9
|
7
|
+
data.tar.gz: dc8d0bb46269b878377c499ba70f96a660e5e575575c794da9350b7b9a4158aa8f6c6c180744788009fc3731c4745fab751cd545839cc92cfb8445a832a451e3
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-zeuswpi (1.0.0)
|
5
|
+
omniauth-oauth2 (~> 1.7.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
faraday (2.3.0)
|
11
|
+
faraday-net_http (~> 2.0)
|
12
|
+
ruby2_keywords (>= 0.0.4)
|
13
|
+
faraday-net_http (2.0.3)
|
14
|
+
hashie (5.0.0)
|
15
|
+
jwt (2.3.0)
|
16
|
+
multi_json (1.15.0)
|
17
|
+
multi_xml (0.6.0)
|
18
|
+
oauth2 (1.4.9)
|
19
|
+
faraday (>= 0.17.3, < 3.0)
|
20
|
+
jwt (>= 1.0, < 3.0)
|
21
|
+
multi_json (~> 1.3)
|
22
|
+
multi_xml (~> 0.5)
|
23
|
+
rack (>= 1.2, < 3)
|
24
|
+
omniauth (2.1.0)
|
25
|
+
hashie (>= 3.4.6)
|
26
|
+
rack (>= 2.2.3)
|
27
|
+
rack-protection
|
28
|
+
omniauth-oauth2 (1.7.2)
|
29
|
+
oauth2 (~> 1.4)
|
30
|
+
omniauth (>= 1.9, < 3)
|
31
|
+
rack (2.2.3)
|
32
|
+
rack-protection (2.2.0)
|
33
|
+
rack
|
34
|
+
ruby2_keywords (0.0.5)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
x86_64-darwin-21
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
omniauth-zeuswpi!
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
2.3.13
|
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-zeuswpi.svg)](https://badge.fury.io/rb/omniauth-zeuswpi)
|
2
|
+
|
3
|
+
# OmniAuth ZeusWPI Zauth Strategy
|
4
|
+
|
5
|
+
Strategy to authenticate with [Zeus WPI](https://zeus.gent) via OAuth2 in OmniAuth, powered by [Zauth](https://github.com/ZeusWPI/zauth).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add to your `Gemfile`
|
10
|
+
```ruby
|
11
|
+
gem 'omniauth-oauth2'
|
12
|
+
gem 'omniauth-zeuswpi'
|
13
|
+
gem 'omniauth-rails_csrf_protection'
|
14
|
+
```
|
15
|
+
|
16
|
+
And run `bundle install`
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
_Note: Change `User` to your specific User model_
|
21
|
+
|
22
|
+
1. Add the strategy to the omniauth config:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
config.omniauth :zeuswpi,
|
26
|
+
Rails.application.credentials.omniauth_client_id,
|
27
|
+
Rails.application.credentials.omniauth_client_secret,
|
28
|
+
token_params: { parse: :json }
|
29
|
+
```
|
30
|
+
|
31
|
+
2. Add a callbacks controller:
|
32
|
+
```ruby
|
33
|
+
class CallbacksController < Devise::OmniauthCallbacksController
|
34
|
+
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
|
35
|
+
skip_before_action :verify_authenticity_token, only: :zeuswpi
|
36
|
+
|
37
|
+
def zeuswpi
|
38
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
39
|
+
sign_in_and_redirect @user, event: :authentication
|
40
|
+
end
|
41
|
+
|
42
|
+
def after_omniauth_failure_path_for(scope)
|
43
|
+
root_path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
3. Add the Devise Omniauth routes:
|
49
|
+
```ruby
|
50
|
+
devise_for :users, controllers: {
|
51
|
+
omniauth_callbacks: 'callbacks'
|
52
|
+
}
|
53
|
+
```
|
54
|
+
|
55
|
+
4. Make your User model omniauthable:
|
56
|
+
```ruby
|
57
|
+
devise :omniauthable, omniauth_providers: %i[zeuswpi]
|
58
|
+
```
|
59
|
+
|
60
|
+
5. Add the `from_omniauth` helper to your `User` model:
|
61
|
+
```ruby
|
62
|
+
def self.from_omniauth(auth)
|
63
|
+
where(name: auth.uid).first_or_create do |user|
|
64
|
+
user.name = auth.uid
|
65
|
+
user.generate_key!
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
```
|
70
|
+
6. Add a button to your website:
|
71
|
+
```
|
72
|
+
<%= button_to "Log in with Zeus WPI",
|
73
|
+
user_zeuswpi_omniauth_authorize_path %>
|
74
|
+
```
|
75
|
+
|
76
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-zeuswpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Naessens, Zeus WPI
|
@@ -34,7 +34,9 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- ".gitignore"
|
36
36
|
- Gemfile
|
37
|
+
- Gemfile.lock
|
37
38
|
- LICENSE
|
39
|
+
- README.md
|
38
40
|
- lib/omniauth-zeuswpi.rb
|
39
41
|
- lib/omniauth/strategies/zeuswpi.rb
|
40
42
|
- lib/omniauth/zeuswpi.rb
|