Posts

Using OAuth2 in Spring Boot App with {okta}

Image
Add the following dependencies in POM file <dependency>     <groupId>com.okta.spring</groupId>     <artifactId>okta-spring-boot-starter</artifactId>     <version>0.2.0</version> </dependency>         <dependency>             <groupId>org.springframework.security.oauth</groupId>             <artifactId>spring-security-oauth2</artifactId>             <version>2.2.0.RELEASE</version>         </dependency> In spring boot main class add the following Bold and Underlined code            import org.springframework.boot.autoconfigure.SpringBootApplication;             import org.springframework.security.oauth2.config.annotation.web.con...

No 'Access-Control-Allow-Origin' header is present on the requested resource

NOTE: This is not a fix for production or when application has to be shown to the client, this is only helpful when UI and Backend   development   are on different   servers   and in production they are actually on same server. For example: While developing UI for any application if there is a need to test it locally pointing it to backend server, in that scenario this is the perfect fix.   For production fix, CORS headers has to be added to the backend server to allow cross origin access. The easy way is to just add the extension in google chrome to allow access using CORS. ( https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en-US ) Just enable this extension whenever you want allow access to no  'access-control-allow-origin' header request. Or In Windows, paste this command in  run  window chrome . exe -- user - data - dir = "C:/Chrome dev session" -- disable - web - security ...

Maven Proxy setting issues for NTLM Proxy Users

Image
Follow the following steps and the problem would be resolved. 1. Download and install cNTLM for windows. 2. Configure cNTLM as shown below: Open cntlm.ini configuration file. Configure cntlm.ini file Set user name. Set domain name Set user's password. Set Proxy IP and Port. Note down Listen port to set in maven's settings.xml file. Now save and close cntlm.ini file. 3. Open maven settings.xml file and set proxy settings as follows:     <settings>        <proxies>              <proxy>                     <active>true</active>                     <protocol>http</protocol>                     <host> 127.0.0.1 </host>                 ...

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:3.1 or one of its dependencies could not be resolved.

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:3.1 or one of its dependencies could not be resolved . First of all, check the maven repositiory server is up. 1. Check Proxy is set up and working First I thought it was a proxy problem, I made sure that maven settings.xml contained the proxy settings (settings.xml can exist in two places one in MAVEN_HOME. The other in %userprofile%.m2\ with the later having higher precedence): <proxy>   <id> optional </id>   <active> true </active>     <protocol> http </protocol>   <username> optional-proxyuser </username>   <password> optional-proxypass </password>   <host> proxy.host.net </host>   <port> 80 </port>   <nonProxyHosts> local.net|some.host.com </nonProxyHosts> </proxy> and checked that the proxy is working by trying...

ASP.Net MVC Core: Javascript files in Areas along with Views (.cschtml)

Areas in MVC allow you to separate your web application into segments, each with their own set of Controllers and Views, for better organization and intuitive access via routing.   Here I want to manage my static java script files particular objects in areas i.e. I want to place my CountryDetail.js and CountryGrid.js files in Areas/Setup/Country Folder along with CountryDetail.cshtml and CountryGrid.cshtml. As you know, in .Net Core, as part of the OWIN pipeline , no static files are rendered by default including those in the "wwwroot" folder. Where things used to be handled in web.config, now everything goes through the OWIN pipeline. You have to add the StaticFile Middleware which will allow those to be rendered. The default implementation allows all files under "wwwroot" to be rendered. public void Configure ( IApplicationBuilder app) {     app. UseStaticFiles (); } Here is the official Microsoft documentation:  Working with StaticFiles...