@@ -19,23 +19,14 @@ init(Req0, State) ->
1919bootstrap_oauth (Req0 , State ) ->
2020 AuthSettings = rabbit_mgmt_wm_auth :authSettings (),
2121 Dependencies = oauth_dependencies (),
22- <<<<<<< HEAD
23- JSContent = import_dependencies (Dependencies ) ++
24- set_oauth_settings (AuthSettings ) ++
25- set_token_auth (AuthSettings , Req0 ) ++
26- export_dependencies (Dependencies ),
27- {ok , cowboy_req :reply (200 , #{<<" content-type" >> => <<" text/javascript; charset=utf-8" >>},
28- JSContent , Req0 ), State }.
29- =======
3022 {Req1 , SetTokenAuth } = set_token_auth (AuthSettings , Req0 ),
3123 JSContent = import_dependencies (Dependencies ) ++
3224 set_oauth_settings (AuthSettings ) ++
3325 SetTokenAuth ++
3426 export_dependencies (Dependencies ),
35-
27+
3628 {ok , cowboy_req :reply (200 , #{<<" content-type" >> => <<" text/javascript; charset=utf-8" >>},
3729 JSContent , Req1 ), State }.
38- >>>>>>> 5 e5521a3c (Use POST + Redirect_with_cookie )
3930
4031set_oauth_settings (AuthSettings ) ->
4132 JsonAuthSettings = rabbit_json :encode (rabbit_mgmt_format :format_nulls (AuthSettings )),
@@ -45,40 +36,35 @@ set_token_auth(AuthSettings, Req0) ->
4536 case proplists :get_value (oauth_enabled , AuthSettings , false ) of
4637 true ->
4738 case cowboy_req :parse_header (<<" authorization" >>, Req0 ) of
48- {bearer , Token } ->
39+ {bearer , Token } ->
4940 {
50- Req0 ,
41+ Req0 ,
5142 [" set_token_auth('" , Token , " ');" ]
5243 };
53- _ ->
44+ _ ->
5445 Cookies = cowboy_req :parse_cookies (Req0 ),
55- case lists :keyfind (? OAUTH2_ACCESS_TOKEN_COOKIE_NAME , 1 , Cookies ) of
56- {_ , Token } ->
46+ case lists :keyfind (? OAUTH2_ACCESS_TOKEN_COOKIE_NAME , 1 , Cookies ) of
47+ {_ , Token } ->
5748 {
5849 cowboy_req :set_resp_cookie (
5950 ? OAUTH2_ACCESS_TOKEN_COOKIE_NAME , <<" " >>, Req0 , #{
6051 max_age => 0 ,
6152 http_only => true ,
6253 path => ? OAUTH2_ACCESS_TOKEN_COOKIE_PATH ,
6354 same_site => strict
64- }),
55+ }),
6556 [" set_token_auth('" , Token , " ');" ]
6657 };
6758 false -> {
68- Req0 ,
59+ Req0 ,
6960 []
7061 }
7162 end
7263 end ;
73- <<<<<<< HEAD
74- false ->
75- []
76- =======
7764 false -> {
78- Req0 ,
65+ Req0 ,
7966 []
8067 }
81- >>>>>>> 5 e5521a3c (Use POST + Redirect_with_cookie )
8268 end .
8369
8470import_dependencies (Dependencies ) ->
0 commit comments