auth1 0.1.0 → 0.2.0

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: 1684f80c656efced4e2627bfd733921f333dc26bdc4485cdbabe4c1127cd282a
4
- data.tar.gz: 53f0226011b26298cb89239457417d5f8d709c83b743bb5cce113af05b966cd5
3
+ metadata.gz: 9cbe8220cdce0cc3e9456969eb995ad9bb70425afaef6f5379804806e3e7fe38
4
+ data.tar.gz: 4dd79d2768e93420123259e50a0257c45487baeb510f8c054199b66a1ecdd864
5
5
  SHA512:
6
- metadata.gz: 7ed09aa9e219e7d4a71e07d0545f7b2bf756475d736d90c427c436226a7dd78011b59ea1a8f99beda0b9a4559f887173cfaa4df4c1bbd9e2e4cd46a0b757d86a
7
- data.tar.gz: 65460fff898584b8b222d9f6ab79832d872b010b276b52b4275955a6de27b996910285d1bb144360cca98d098669278f60e896bdee1cc90c3c213b2756927244
6
+ metadata.gz: 81187a4a8dc57e6e692e93c2fc0896637ea8dcdfb9686d2dfb2bdd38f6b58db7d1b5e821fe532387bb686fbe5aaa10924ec89236e2d5eb6d50867a483b4f005c
7
+ data.tar.gz: a69a4ddeb703bd03beaddbcf7001649e36ec2a5815491e6781cb26a55fa9d59dea81dcabf64a331d52f6d3c4a56e112589a1c158cfe24deed5b04317a37ec48f
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,7 +16,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
22
  load 'rails/tasks/statistics.rake'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  class ApplicationController < ActionController::Base
3
5
  protect_from_forgery with: :exception
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency 'auth1/application_controller'
4
+
5
+ module Auth1
6
+ class SessionsController < ApplicationController
7
+ def callback
8
+ # This stores all the user information that came from Auth0 and the IdP
9
+ # See also: https://github.com/auth0/omniauth-auth0#authentication-hash
10
+ session[:userinfo] = request.env['omniauth.auth']
11
+
12
+ # Redirect to the URL you want after successful auth
13
+ redirect_to request.env['omniauth.origin']
14
+ end
15
+
16
+ def failure
17
+ # show a failure page or redirect to an error page
18
+ @error_msg = request.params['message']
19
+ end
20
+
21
+ def logout
22
+ reset_session
23
+ redirect_to auth0_logout_url
24
+ end
25
+
26
+ private
27
+
28
+ def auth0_logout_url
29
+ request_params = {
30
+ client_id: ENV['AUTH0_CLIENT_ID'],
31
+ returnTo: 'http://localhost:3000/' # TODO
32
+ }
33
+
34
+ URI::HTTPS.build(
35
+ host: ENV['AUTH0_DOMAIN'],
36
+ path: '/v2/logout',
37
+ query: request_params.to_query
38
+ ).to_s
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  module ApplicationHelper
3
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Auth1
4
+ module SessionsHelper
5
+ def user_signed_in?
6
+ session['userinfo'].present? && session['userinfo']['uid'].present?
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  class ApplicationJob < ActiveJob::Base
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  class ApplicationMailer < ActionMailer::Base
3
5
  default from: 'from@example.com'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  class ApplicationRecord < ActiveRecord::Base
3
5
  self.abstract_class = true
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ Auth1::Engine.config.middleware.use OmniAuth::Builder do
4
+ provider(
5
+ :auth0,
6
+ ENV['AUTH0_CLIENT_ID'],
7
+ ENV['AUTH0_CLIENT_SECRET'],
8
+ ENV['AUTH0_DOMAIN'],
9
+ callback_path: '/auth/auth0/callback',
10
+ authorize_params: {
11
+ scope: 'openid email profile'
12
+ }
13
+ )
14
+ end
data/config/routes.rb CHANGED
@@ -1,2 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Auth1::Engine.routes.draw do
4
+ get 'auth/auth0/callback', to: 'sessions#callback'
5
+ get 'auth/failure', to: 'sessions#failure'
6
+ get 'logout', to: 'sessions#logout'
2
7
  end
data/lib/auth1/engine.rb CHANGED
@@ -1,5 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
4
  class Engine < ::Rails::Engine
3
5
  isolate_namespace Auth1
6
+
7
+ initializer :auth1 do
8
+ ActiveSupport.on_load(:action_controller) do
9
+ helper Auth1::Engine.helpers
10
+ end
11
+ end
4
12
  end
5
13
  end
data/lib/auth1/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Auth1
2
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
3
5
  end
data/lib/auth1.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "auth1/engine"
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-auth0'
4
+ require 'auth1/engine'
2
5
 
3
6
  module Auth1
4
- # Your code goes here...
5
7
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :auth1 do
3
4
  # # Task goes here
metadata CHANGED
@@ -1,91 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joon Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-04 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: omniauth-auth0
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.2
19
+ version: '2.3'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 6.0.2.2
22
+ version: 2.3.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 6.0.2
29
+ version: '2.3'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 6.0.2.2
32
+ version: 2.3.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: omniauth-auth0
34
+ name: omniauth-rails_csrf_protection
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.3'
39
+ version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 2.3.1
42
+ version: 0.1.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '2.3'
49
+ version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 2.3.1
52
+ version: 0.1.2
53
53
  - !ruby/object:Gem::Dependency
54
- name: omniauth-rails_csrf_protection
54
+ name: rails
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.1'
59
+ version: 6.0.2
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.1.2
62
+ version: 6.0.2.2
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.1'
69
+ version: 6.0.2
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 0.1.2
72
+ version: 6.0.2.2
73
73
  - !ruby/object:Gem::Dependency
74
- name: sqlite3
74
+ name: dotenv-rails
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '2.7'
77
80
  - - ">="
78
81
  - !ruby/object:Gem::Version
79
- version: '0'
82
+ version: 2.7.5
80
83
  type: :development
81
84
  prerelease: false
82
85
  version_requirements: !ruby/object:Gem::Requirement
83
86
  requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.7'
84
90
  - - ">="
85
91
  - !ruby/object:Gem::Version
86
- version: '0'
92
+ version: 2.7.5
87
93
  - !ruby/object:Gem::Dependency
88
94
  name: rubocop
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.81'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '0.81'
107
+ - !ruby/object:Gem::Dependency
108
+ name: sqlite3
89
109
  requirement: !ruby/object:Gem::Requirement
90
110
  requirements:
91
111
  - - ">="
@@ -111,11 +131,14 @@ files:
111
131
  - app/assets/config/auth1_manifest.js
112
132
  - app/assets/stylesheets/auth1/application.css
113
133
  - app/controllers/auth1/application_controller.rb
134
+ - app/controllers/auth1/sessions_controller.rb
114
135
  - app/helpers/auth1/application_helper.rb
136
+ - app/helpers/auth1/sessions_helper.rb
115
137
  - app/jobs/auth1/application_job.rb
116
138
  - app/mailers/auth1/application_mailer.rb
117
139
  - app/models/auth1/application_record.rb
118
140
  - app/views/layouts/auth1/application.html.erb
141
+ - config/initializers/auth0.rb
119
142
  - config/routes.rb
120
143
  - lib/auth1.rb
121
144
  - lib/auth1/engine.rb