@@ -78,31 +78,31 @@ public function validate(AccessToken $access_token, IClient $client)
7878 'resource server is disabled! '
7979 );
8080 }
81- //check resource server ip address
82- if (!$ resource_server ->isOwn ($ current_ip ))
83- {
84- throw new BearerTokenDisclosureAttemptException
85- (
86- sprintf
81+ if (config ('oauth2.validate_resource_server_ip ' , false )) {
82+ //check resource server ip address
83+ if (!$ resource_server ->isOwn ($ current_ip )) {
84+ throw new BearerTokenDisclosureAttemptException
8785 (
88- 'resource server ip (%s) differs from current request ip %s ' ,
89- $ resource_server ->getIPAddresses (),
90- $ current_ip
91- )
92- );
93- }
94- // check if current ip belongs to a registered resource server audience
95- if (!$ this ->token_service ->checkAccessTokenAudience ($ access_token , $ current_ip ))
96- {
97- throw new BearerTokenDisclosureAttemptException
98- (
99- sprintf
86+ sprintf
87+ (
88+ 'resource server ip (%s) differs from current request ip %s ' ,
89+ $ resource_server ->getIPAddresses (),
90+ $ current_ip
91+ )
92+ );
93+ }
94+ // check if current ip belongs to a registered resource server audience
95+ if (!$ this ->token_service ->checkAccessTokenAudience ($ access_token , $ current_ip )) {
96+ throw new BearerTokenDisclosureAttemptException
10097 (
101- 'access token current audience (%s) does not match with current request ip %s ' ,
102- $ access_token ->getAudience (),
103- $ current_ip
104- )
105- );
98+ sprintf
99+ (
100+ 'access token current audience (%s) does not match with current request ip %s ' ,
101+ $ access_token ->getAudience (),
102+ $ current_ip
103+ )
104+ );
105+ }
106106 }
107107 }
108108}
0 commit comments