@@ -18,25 +18,23 @@ def authorization_url
18
18
end
19
19
20
20
def load_identity ( **params )
21
- response = OneLogin ::RubySaml ::Response . new ( params [ :SAMLResponse ] , { **config [ :response_settings ] , settings : create_settings } )
21
+ response = OneLogin ::RubySaml ::Response . new ( params [ :SAMLResponse ] ,
22
+ { **config [ :response_settings ] , settings : create_settings } )
22
23
attributes = response . attributes
23
24
24
25
Identity . new ( config [ :provider_name ] ,
25
26
response . name_id ,
26
27
find_attribute ( attributes , config [ :attribute_statements ] [ :username ] ) ,
27
28
find_attribute ( attributes , config [ :attribute_statements ] [ :email ] ) ,
28
29
find_attribute ( attributes , config [ :attribute_statements ] [ :firstname ] ) ,
29
- find_attribute ( attributes , config [ :attribute_statements ] [ :lastname ] )
30
- )
30
+ find_attribute ( attributes , config [ :attribute_statements ] [ :lastname ] ) )
31
31
end
32
32
33
33
private
34
34
35
35
def find_attribute ( attributes , attribute_statements )
36
36
attribute_statements . each do |statement |
37
- unless attributes [ statement ] . nil?
38
- return attributes [ statement ]
39
- end
37
+ return attributes [ statement ] unless attributes [ statement ] . nil?
40
38
end
41
39
nil
42
40
end
@@ -59,10 +57,9 @@ def create_settings
59
57
60
58
def config
61
59
config = config_loader
62
- if config_loader . is_a? ( Proc )
63
- config = config_loader . call
64
- end
60
+ config = config_loader . call if config_loader . is_a? ( Proc )
65
61
62
+ # rubocop:disable Layout/LineLength
66
63
config [ :provider_name ] ||= :saml
67
64
config [ :response_settings ] ||= { }
68
65
config [ :settings ] ||= { }
@@ -71,10 +68,11 @@ def config
71
68
config [ :attribute_statements ] [ :email ] ||= %w[ email mail http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress http://schemas.microsoft.com/ws/2008/06/identity/claims/emailaddress ]
72
69
config [ :attribute_statements ] [ :firstname ] ||= %w[ first_name firstname firstName http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname http://schemas.microsoft.com/ws/2008/06/identity/claims/givenname ]
73
70
config [ :attribute_statements ] [ :lastname ] ||= %w[ last_name lastname lastName http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname http://schemas.microsoft.com/ws/2008/06/identity/claims/surname ]
71
+ # rubocop:enable Layout/LineLength
74
72
75
73
config
76
74
end
77
75
end
78
76
end
79
77
end
80
- end
78
+ end
0 commit comments