self-auth-rails 0.1.2 → 0.1.3
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 +4 -4
- data/app/assets/config/self-auth-rails/app.js +17 -4
- data/app/assets/config/self-auth-rails/channels/messages_channel.js +9 -2
- data/app/services/self_auth_response_manager_service.rb +1 -6
- data/app/views/self_auth_rails/sessions/new.html.erb +1 -0
- data/lib/self-auth-rails/version.rb +1 -1
- data/lib/self-auth-rails.rb +5 -5
- data/lib/tasks/initializer.rb.tpl +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f810144382bd25fa0222496cef327c9173e64be241d92936bc48081974e8e05
|
4
|
+
data.tar.gz: 0efab5872279cfc516d50cdc4d6bc840a97c60262b4e35c7d37c81ee12cb75e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c1050ec2e42551cd0c627e25d6aac96e5d69996c422249f781604ee28b7c89f1cda292df733fd66f19bb8755453cd3a57f275a40d183d8b6febcc1fbb6f540f
|
7
|
+
data.tar.gz: bed299ce81b58f2a1135a97e04db73de7d29c37c0516a19746dfd909cc3830c13c5b32028526c75f988fc56225dbfef1d694444582eca3de5c000ce1419b4418
|
@@ -1,11 +1,15 @@
|
|
1
1
|
/* Initialize app when page loads */
|
2
2
|
$(function(){
|
3
|
+
if(App.cable.subscriptions.subscriptions.length > 0) {
|
4
|
+
if(App.cable.subscriptions.subscriptions[0].identifier.includes("MessagesChannel")) {
|
5
|
+
return
|
6
|
+
}
|
7
|
+
}
|
3
8
|
var Messages = App.cable.subscriptions.create({
|
4
9
|
channel:'MessagesChannel',
|
5
10
|
conversation_id: connectionID()
|
6
11
|
}, {
|
7
12
|
received: function(data) {
|
8
|
-
console.log(data);
|
9
13
|
if(data.type == "info") {
|
10
14
|
if(data.status == "completed") {
|
11
15
|
console.log("info request");
|
@@ -16,7 +20,13 @@ $(function(){
|
|
16
20
|
message = data.message
|
17
21
|
}
|
18
22
|
// TODO: this id no longer exists...
|
19
|
-
|
23
|
+
document.querySelector('#info_messages').insertAdjacentHTML(
|
24
|
+
'afterbegin',
|
25
|
+
`<div class='alert alert-danger'>
|
26
|
+
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
|
27
|
+
${message}
|
28
|
+
</div>`
|
29
|
+
)
|
20
30
|
}
|
21
31
|
} else {
|
22
32
|
$("#messages").removeClass('hidden');
|
@@ -67,9 +77,12 @@ $(function(){
|
|
67
77
|
if(data.status == "errored") {
|
68
78
|
message = data.message
|
69
79
|
}
|
70
|
-
|
80
|
+
document.querySelector('#info_messages').insertAdjacentHTML(
|
81
|
+
'afterbegin',
|
82
|
+
`<div class="alert alert-warning alert-dismissible show fade"><div class="alert-body"><button class="close" data-dismiss="alert"><span>×</span></button>${message}</div></div>`
|
83
|
+
)
|
71
84
|
|
72
|
-
$('#
|
85
|
+
$('#info_messages').show();
|
73
86
|
$('#process').addClass("hidden");
|
74
87
|
$('#non-dl-container').removeClass("hidden");
|
75
88
|
|
@@ -105,9 +105,16 @@ function uuidv4() {
|
|
105
105
|
},
|
106
106
|
error: function (e) {
|
107
107
|
if(e.status == 502) {
|
108
|
-
|
108
|
+
document.querySelector('#info_messages').insertAdjacentHTML(
|
109
|
+
'afterbegin',
|
110
|
+
`<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>Request timed out, try again later</div>`
|
111
|
+
)
|
112
|
+
|
109
113
|
} else {
|
110
|
-
|
114
|
+
document.querySelector('#info_messages').insertAdjacentHTML(
|
115
|
+
'afterbegin',
|
116
|
+
`<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>${e.responseJSON.error}</div>`
|
117
|
+
)
|
111
118
|
}
|
112
119
|
$("#profile_help_block").hide();
|
113
120
|
}
|
@@ -27,7 +27,7 @@ class SelfAuthResponseManagerService
|
|
27
27
|
return
|
28
28
|
end
|
29
29
|
|
30
|
-
unless
|
30
|
+
unless SelfAuthRails.permitted_auth.call(self_auth_response.from)
|
31
31
|
broadcast_status_change channel, STATUS_ERR, message: 'You are forbidden to access this service'
|
32
32
|
return
|
33
33
|
end
|
@@ -69,9 +69,4 @@ class SelfAuthResponseManagerService
|
|
69
69
|
@broadcaster.broadcast channel, { status: status, token: token, message: message, type: type }
|
70
70
|
end
|
71
71
|
|
72
|
-
# checks if the given id is in the admins list
|
73
|
-
def admin?(id)
|
74
|
-
return true unless ENV.include? 'ADMIN_IDS'
|
75
|
-
ENV['ADMIN_IDS'].split(',').include? id
|
76
|
-
end
|
77
72
|
end
|
@@ -12,6 +12,7 @@
|
|
12
12
|
<div class="col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3 col-lg-6 offset-lg-3 col-xl-6 offset-xl-3">
|
13
13
|
<div class="card card-primary">
|
14
14
|
<div class="card-body">
|
15
|
+
<div id="info_messages"></div>
|
15
16
|
|
16
17
|
<div id="dl-container" class="hidden">
|
17
18
|
<div class="col-xs-12">
|
data/lib/self-auth-rails.rb
CHANGED
@@ -8,7 +8,8 @@ module SelfAuthRails
|
|
8
8
|
:fact_mapping,
|
9
9
|
:authenticated_path,
|
10
10
|
:authenticated_path,
|
11
|
-
:layout
|
11
|
+
:layout,
|
12
|
+
:permitted_auth
|
12
13
|
|
13
14
|
class Engine < ::Rails::Engine
|
14
15
|
default_auth_facts = [:display_name]
|
@@ -18,6 +19,9 @@ module SelfAuthRails
|
|
18
19
|
unless SelfAuthRails::self_client.nil?
|
19
20
|
SelfAuthRails.auth_facts ||= default_auth_facts
|
20
21
|
SelfAuthRails.authenticated_path ||= default_authenticated_path
|
22
|
+
if SelfAuthRails.permitted_auth.nil?
|
23
|
+
SelfAuthRails.permitted_auth ||= Proc.new { |selfid| true }
|
24
|
+
end
|
21
25
|
|
22
26
|
response_manager = SelfAuthResponseManagerService.new(ActionCable.server)
|
23
27
|
|
@@ -44,8 +48,4 @@ module SelfAuthRails
|
|
44
48
|
yield self
|
45
49
|
end
|
46
50
|
|
47
|
-
def authenticated_path
|
48
|
-
SelfAuthRails::authenticated_path || SelfAuthRails::default_authenticated_path
|
49
|
-
end
|
50
|
-
|
51
51
|
end
|
@@ -44,5 +44,11 @@ if defined?(Rails::Server) && !defined?(::SelfClient)
|
|
44
44
|
# to request and store facts during the authentication process with
|
45
45
|
# config.auth_facts
|
46
46
|
config.fact_mapping = { display_name: :name }
|
47
|
+
|
48
|
+
# Defines if a given user is permitted to access the service or not.
|
49
|
+
# config.permitted_auth = Proc.new do |selfid|
|
50
|
+
# true
|
51
|
+
# end
|
52
|
+
|
47
53
|
end
|
48
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: self-auth-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrià Cidre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|