File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -20,17 +20,22 @@ use Airbrake::Rack::Middleware if ENV['AIRBRAKE_PROJECT_ID'].present?
2020map '/sidekiq' do
2121 unless MR . env == 'development'
2222 use Rack ::Auth ::Basic , 'Protected Area' do |username , password |
23- username_matches = Rack ::Utils . secure_compare (
24- Digest ::SHA256 . hexdigest ( username ) ,
25- Digest ::SHA256 . hexdigest ( ENV . fetch ( 'SIDEKIQ_USERNAME' , nil ) )
26- )
27-
28- password_matches = Rack ::Utils . secure_compare (
29- Digest ::SHA256 . hexdigest ( password ) ,
30- Digest ::SHA256 . hexdigest ( ENV . fetch ( 'SIDEKIQ_PASSWORD' , nil ) )
31- )
32-
33- username_matches && password_matches
23+ if ENV . key? ( 'SIDEKIQ_USERNAME' ) && ENV . key? ( 'SIDEKIQ_PASSWORD' )
24+ username_matches = Rack ::Utils . secure_compare (
25+ Digest ::SHA256 . hexdigest ( username ) ,
26+ Digest ::SHA256 . hexdigest ( ENV . fetch ( 'SIDEKIQ_USERNAME' , nil ) )
27+ )
28+
29+ password_matches = Rack ::Utils . secure_compare (
30+ Digest ::SHA256 . hexdigest ( password ) ,
31+ Digest ::SHA256 . hexdigest ( ENV . fetch ( 'SIDEKIQ_PASSWORD' , nil ) )
32+ )
33+
34+ username_matches && password_matches
35+ else
36+ MR . logger . warn ( "SIDEKIQ_USERNAME or SIDEKIQ_PASSWORD is missing" )
37+ false
38+ end
3439 end
3540 end
3641
You can’t perform that action at this time.
0 commit comments