Some Common issues -spring microsevices ,and loging using android app

 Issue 1: http status 403 forbidden

environment : Spring boot microservcei and spring cloud api gateway

when sending http request , enven if the request deos not require any authintication .


Reason:

In the security microservice app, In the webSecurity class , the code in the configure method prevent any request that is not comming from a specific ip

protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        http.authorizeRequests().antMatchers("/**").hasIpAddress(env.getProperty("gateway.ip"))
             .and()
        .addFilter(getAuthenticationFilter());
        http.headers().frameOptions().disable();
    }


Solution

 

comment the line "antMatches....

code changed to 

protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        //http.authorizeRequests().antMatchers("/**").hasIpAddress(env.getProperty("gateway.ip"))
        http.authorizeRequests().anyRequest().permitAll()
        .and()
        .addFilter(getAuthenticationFilter());
        http.headers().frameOptions().disable();
    }

and problem solved

 

Issue 2:

When trying to login using the login api from the mobile release , I got a network error

environment: Angular ,ionic capacitor

Reason 

The api is not on https

 

Solution

add this line to 

android:usesCleartextTraffic="true
under the application tag
 
 <application
android:allowBackup="true"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

 


Comments

Popular posts from this blog

Another user has changed the row with primary key oracle.jbo.Key[12 ].

weblogic windows JPS-01050: Opening of wallet based credential store failed. Reason java.io.IOException: Failed to lock cwallet.sso.lck

Working With File Throgh WebUtill