@@ -4,33 +4,13 @@ def self.configuration
4
4
@@configuration ||= Configuration . default_configuration
5
5
end
6
6
7
- def self . reset_configuration
8
- @@configuration = Configuration . default_configuration
9
- end
10
-
11
7
class Configuration
12
8
13
- REQUEST_METHOD = 'REQUEST_METHOD' . freeze
14
- GET = 'GET' . freeze
15
- PATH_INFO = 'PATH_INFO' . freeze
16
- DIAGNOSTIC = '/diagnostic/' . freeze
17
-
18
9
attr_accessor :log_dir , :database_connection , :auto_migrate_db , :use_hal_browser , :html_pact_renderer
19
10
attr_accessor :validate_database_connection_config , :enable_diagnostic_endpoints , :version_parser
20
- attr_accessor :use_case_sensitive_resource_names , :basic_auth_predicates
11
+ attr_accessor :use_case_sensitive_resource_names
21
12
attr_writer :logger
22
13
23
- def initialize
24
- @basic_auth_config = { }
25
- @basic_auth_predicates = [
26
- [ :diagnostic , -> ( env ) { env [ PATH_INFO ] . start_with? DIAGNOSTIC } ] ,
27
- [ :app_read , -> ( env ) { env [ REQUEST_METHOD ] == GET } ] ,
28
- [ :app_write , -> ( env ) { env [ REQUEST_METHOD ] != GET } ] ,
29
- [ :app , -> ( env ) { !env [ PATH_INFO ] . start_with? DIAGNOSTIC } ] ,
30
- [ :all , -> ( env ) { true } ]
31
- ]
32
- end
33
-
34
14
def logger
35
15
@logger ||= create_logger log_path
36
16
end
@@ -49,35 +29,15 @@ def self.default_configuration
49
29
config
50
30
end
51
31
52
- # public
53
32
def self . default_html_pact_render
54
33
lambda { |pact |
55
34
require 'pact_broker/api/renderers/html_pact_renderer'
56
35
PactBroker ::Api ::Renderers ::HtmlPactRenderer . call pact
57
36
}
58
37
end
59
38
60
- # public
61
- def protect_with_basic_auth scopes , credentials
62
- [ *scopes ] . each do | scope |
63
- basic_auth_config [ scope ] = credentials
64
- end
65
- end
66
-
67
- # private
68
- def protect_with_basic_auth? scope
69
- !!basic_auth_credentials_for ( scope )
70
- end
71
-
72
- # private
73
- def basic_auth_credentials_for scope
74
- basic_auth_config [ scope ] || basic_auth_config [ :all ]
75
- end
76
-
77
39
private
78
40
79
- attr_reader :basic_auth_config
80
-
81
41
def create_logger path
82
42
FileUtils ::mkdir_p File . dirname ( path )
83
43
logger = Logger . new ( path )
0 commit comments