Azure Redirect URI showing directory path - azure-active-directory

I Created web application using azure authentication. I created app registration with secrets key.
Its working fine while debugging but After publish the project in localhost its won't working. its showing folder dir path only.
My Code
if (Request.IsAuthenticated)
{
Response.Redirect("default.aspx",false);
}
else
{
HttpContext.Current.GetOwinContext().Authentication.Challenge(new
AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
Web Config
<add key="ida:GraphResourceId" value="https://graph.microsoft.com" />
<add key="ida:GraphUserUrl" value="https://graph.microsoft.com/{0}/me?api-version=2013-11-08" />
<add key="todo:TodoListResourceid" value="api://xxxxxxxxxxx" />
<add key="todo:TodoListBaseAddress" value="http://localhost/Test/" />
<add key="ida:ClientId" value="xxxxxxx" />
<add key="ida:AppKey" value="xxxxxxxxx" />
<add key="ida:Tenant" value="aaaaaaaaaaa" />
<add key="ida:AADInstance" value="https://login.microsoftonline.com/{0}" />
<add key="ida:RedirectUri" value="http://localhost/Test" />
Error Image :

Related

WPF log4net is not writing to the log file [duplicate]

This question already has an answer here:
WPF-Log4Net used inside VSIX extension did not output log when installed at target VS
(1 answer)
Closed 4 years ago.
I have a WPF solution. I downloaded log4net dll, I added log4net.config and had set the "Copy to Output Directory" value as "Copy always".
log4net.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="myapp.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
And I added the below line in AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
then the below code in my TestWindowControl.xaml.cs
public partial class TestWindowControl : UserControl
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public TestWindowControl()
{
XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
log.Info("info testing");
log.Debug("debug testing");
log.Error("error testing");
log.Fatal("fatal testing");
log.Warn("warn testing");
}
}
But logs are not writing to the file. It's working in Console application but not working for WPF. Am I missing something?
Try to set the filter inside appender
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="WARN" />
<levelMax value="ERROR" />
</filter>

AngularJS and URL Rewrite to HTTPS

So I have ui-router in my application and everything has been working fine.
I was asked to make the account area of the site forced HTTPS so I set up this rule:
I have a link on the main "view" that takes you to the login page and the link looks just like this:
<a class="link-primary" ui-sref="login" ng-switch-default>Sign in</a>
The state rule set up looks like this:
.state('login', {
url: '/account/signin',
params: {
returnState: null,
returnParams: null
},
templateUrl: '/assets/tpl/account/signin.tpl.html',
controller: 'LoginController',
controllerAs: 'controller',
resolve: {
pageTitle: ['PageHead', function (service) {
service.setTitle('Kudos Sports - Login');
}]
}
})
When I click the link I get an error message:
XMLHttpRequest cannot load https://kudos-topspindigital.azurewebsites.net/assets/tpl/account/signin.tpl.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://kudos-topspindigital.azurewebsites.net' is therefore not allowed access.
I can type the url (https://kudos-topspindigital.azurewebsites.net/account/signin) and this works without any issues. I can even do it by omitting the https protocol and it will redirect with no issues, so I can only assume there is something wrong with angularJS.
Can someone help me fix my issue?
Try add HTTP header in your server response by:
"Access-Control-Allow-Origin", "*"
This time, use server side script to return HTML instead pure html, for example, in PHP
<?php
header("Access-Control-Allow-Origin: *");
Tbh the best way for me to do this was to set up a rule that pushed everything to HTTPS, not just the account stuff.
<rule name="Redirect .com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="kudos-sports.co.uk" />
<add input="{HTTP_HOST}" pattern="kudos-sports.com" />
<add input="{HTTP_HOST}" pattern="kudos-sportswear.co.uk" />
<add input="{HTTP_HOST}" pattern="kudos-sportswear.com" />
<add input="{HTTP_HOST}" pattern="www.kudos-sports.co.uk" />
<add input="{HTTP_HOST}" pattern="www.kudos-sportswear.co.uk" />
<add input="{HTTP_HOST}" pattern="www.kudos-sportswear.com" />
<add input="{HTTP_HOST}" pattern="kudos-sports.azurewebsites.net" />
</conditions>
<action type="Redirect" url="https://www.kudos-sports.com{REQUEST_URI}" />
</rule>

How to get google adwords reports in salesforce?

Hi I am developing application in salesforce for accessing the google adwords reports data for e.g. ADGROUP_PERFORMANCE_REPORT. I am sending http post request to https://adwords.google.com/api/adwords/reportdownload/v201302, and I am using apex(java like language in salesforce) below is my request.
Http h = new Http();
HttpRequest req = new HttpRequest();
GoogleAuthorization auth=new GoogleAuthorization();
req.setHeader('Authorization', 'GoogleLogin ' + auth.token);
req.setHeader('UserAgent', 'XXXXX');
req.setHeader('developerToken','XXXXXXXX');
req.setHeader('clientCustomerId','XXXXXXXX');
req.setEndPoint('https://adwords.google.com/api/adwords/reportdownload/v201302');
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setMethod('POST');
string xml='<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201302">'+
'<selector>'+
'<fields>CampaignId</fields>'+
'<fields>Id</fields>'+
'<fields>Impressions</fields>'+
'<fields>Clicks</fields>'+
'<fields>Cost</fields>'+
'<predicates>'+
'<field>Status</field>'+
'<operator>IN</operator>'+
'<values>ENABLED</values>'+
'<values>PAUSED</values>'+
'</predicates>'+
'</selector>'+
'<reportName>Custom Adgroup Performance Report</reportName>'+
'<reportType>ADGROUP_PERFORMANCE_REPORT</reportType>'+
'<dateRangeType>LAST_7_DAYS</dateRangeType>'+
'<downloadFormat>XML</downloadFormat>'+
'</reportDefinition>';
req.setBody('__rdxml='+EncodingUtil.urlEncode(xml, 'UTF-8'));
HttpResponse res=h.send(req);
After requesting i am getting the AuthenticationError System.HttpResponse[Status=Bad Request, StatusCode=400].
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>AuthenticationError.USER_ID_INVALID</type><trigger><null></trigger><fieldPath></fieldPath></ApiError></reportDownloadError>
However my loginid and password is correct. What i am doing wrong can anybody please help!
Check your app's configuration.
You must have there something like this :
<AdWordsApi>
<add key="MaskCredentials" value="true" />
<add key="EnableGzipCompression" value="true" />
<add key="ProxyServer" value="" />
<add key="ProxyUser" value="" />
<add key="ProxyPassword" value="" />
<add key="ProxyDomain" value="" />
<add key="UserAgent" value="*******" />
<add key="DeveloperToken" value="*******" />
<add key="ClientCustomerId" value="*******" />
<add key="SkipReportHeader" value="false" />
<add key="SkipReportSummary" value="false" />
<add key="OAuth2ClientId" value="*******" />
<add key="OAuth2ClientSecret" value="*******" />
<add key="OAuth2Mode" value="APPLICATION" />
<add key="OAuth2RefreshToken" value="1/*******" />
</AdWordsApi>
fill all required values *****.

After successful LDAP authentication takes to login

I am new spring-security I did spring authentication with ActiveDirectory, It was working after adding
<beans:bean id="myauthenticationrpovider" class="com.holcim.acl.rm.security.MyAuthoritySupplementingProvider">
<beans:constructor-arg ref="ldapActiveDirectoryAuthProvider" />
and bean code as follows
public class MyAuthoritySupplementingProvider implements AuthenticationProvider {
private AuthenticationProvider delegate;
public MyAuthoritySupplementingProvider(AuthenticationProvider delegate) {
this.delegate = delegate;
}
public Authentication authenticate(Authentication authentication) {
final Authentication a = delegate.authenticate(authentication);
//get first username and full User Name from a i.e Authentication.
Object auth = a.getPrincipal();
String username;
String userFullName;
if(auth instanceof LdapUserDetailsImpl){
LdapUserDetailsImpl userDetails = (LdapUserDetailsImpl) auth;
String[] dn = userDetails.getDn().split(",");
String[] temp = dn[0].split("=");
userFullName = temp[1];
username = ((LdapUserDetailsImpl) auth).getUsername();
logger.debug("AD Authentication done ");
logger.debug(userDetails.getDn());
logger.debug("User Full Name " + temp[1]);
logger.debug("UserName is :: "+ username);
}
// Load additional authorities and create an Authentication object
//final List<GrantedAuthority> authorities = loadRolesFromDatabaseHere();
List<AclAuthority> authorities = new ArrayList<AclAuthority>();
authorities.add(AclAuthority.ROLE_ADMIN);
return new AbstractAuthenticationToken(authorities) {
public Object getCredentials() {
throw new UnsupportedOperationException();
}
public Object getPrincipal() {
return a.getPrincipal();
}
};
}
#Override
public boolean supports(Class<?> authentication) {
return delegate.supports(authentication);
}
}
application-security.xml as follows
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- HTTP security configurations -->
<http auto-config="true" use-expressions="true">
<form-login login-processing-url="/static/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" />
<logout logout-url="/static/j_spring_security_logout" />
<!-- Configure these elements to secure URIs in your application -->
<intercept-url pattern="/choices/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/member/**" access="isAuthenticated()" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/login/**" access="permitAll" />
<intercept-url pattern="/**" access="isAuthenticated()" />
</http>
<!-- Active directory authentication added by Kamlesh A. -->
<!-- LDAP server details -->
<authentication-manager>
<authentication-provider ref="myauthenticationrpovider" />
</authentication-manager>
<beans:bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<beans:constructor-arg value="in.mycompany.net" />
<beans:constructor-arg value="ldap://XXX.XXX.XXX.XXX:PPP" />
<!--<beans:property name="authoritiesMapper" ref="grantedAuthoritiesMapper" />-->
<beans:property name="useAuthenticationRequestCredentials" value="true" />
<beans:property name="convertSubErrorCodesToExceptions" value="true" />
</beans:bean>
<beans:bean id="myauthenticationrpovider" class="com.holcim.acl.rm.security.MyAuthoritySupplementingProvider">
<beans:constructor-arg ref="ldapActiveDirectoryAuthProvider" />
</beans:bean>
</beans:beans>
I have gone through so questions
Spring Security redirect to previous page after successful login
as well as
Unexpected redirect to login page after successful login
after successfull login it takes to
http://localhost:8080/static/j_spring_security_check
But if I try to open anyother url it again take to login

Impossible to create windows forms application using BusinessLogic of Nopcommerce v.1.9

My client ask me something who seems me very simple to do.
He has nopcommerce 1.9 web site , and he wish develop a simple windows forms application to modify clients adresses.
So i tryed to configure a news windows forms project :
static void Main(string[] args)
{
// Code that runs on application startup
NopConfig.Init();
//initialize IoC
IoC.InitializeWith(new DependencyResolverFactory());
//initialize task manager
TaskManager.Instance.Initialize(NopConfig.ScheduleTasks);
TaskManager.Instance.Start();
//open
new FormClient().Show();
TaskManager.Instance.Stop();
}
Then i create a service manager who expose data :
public class ServiceManager
{
public ICustomerService CustomerService;
public ServiceManager()
{
var dbContext = IoC.Resolve<NopObjectContext>();
CustomerService = new CustomerService(dbContext);
}
}
And impossible to access CustomerService methods because resolve method don't find the concrete class to instantiate for NopObjectContext;
(you can find nop commerce 1.9 in this location :
http://nopcommerce.codeplex.com/downloads/get/176949 )
Finally , it works :
App.config must be :
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="NopConfig" type="NopSolutions.NopCommerce.BusinessLogic.Configuration.NopConfig, Nop.BusinessLogic" requirePermission="false"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="NopSolutions.NopCommerce.BusinessLogic.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="dependencyResolverTypeName" value="NopSolutions.NopCommerce.BusinessLogic.Infrastructure.UnityDependencyResolver, Nop.BusinessLogic" />
</appSettings>
<connectionStrings>
<add name="NopEntities" connectionString="metadata=res://*/Data.NopModel.csdl|res://*/Data.NopModel.ssdl|res://*/Data.NopModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EGG-BANKS;Initial Catalog=nopvierge2;Persist Security Info=True;User ID=sa;Password=sqlserver;MultipleActiveResultSets=True;Application Name=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="NopSqlConnection" connectionString="Data Source=DAVID-TOSH\SQLEXPRESS;Initial Catalog=nop;Integrated Security=True;Persist Security Info=False;MultipleActiveResultSets=True;Connect Timeout=120" />
</connectionStrings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<applicationSettings>
<NopSolutions.NopCommerce.BusinessLogic.Properties.Settings>
<setting name="Nop_BusinessLogic_Clickatell_PushServerWS" serializeAs="String">
<value>http://api.clickatell.com/soap/webservice_vs.php</value>
</setting>
<setting name="Nop_BusinessLogic_EuropaCheckVatService_checkVatService" serializeAs="String">
<value>http://ec.europa.eu/taxation_customs/vies/services/checkVatService</value>
</setting>
</NopSolutions.NopCommerce.BusinessLogic.Properties.Settings>
</applicationSettings>
<NopConfig>
<SqlServer ConnectionStringName="NopSqlConnection"/>
<ScheduleTasks>
<Thread seconds="60">
<!--do NOT enable ClearCache task if you have enabled tracking online users-->
<task name="ClearCache" type="NopSolutions.NopCommerce.BusinessLogic.Caching.ClearCacheTask, Nop.BusinessLogic" enabled="false" stopOnError="false"/>
<task name="PurgeOnlineUsers" type="NopSolutions.NopCommerce.BusinessLogic.Audit.UsersOnline.PurgeOnlineUsersTask, Nop.BusinessLogic" enabled="true" stopOnError="false"/>
<task name="Emails" type="NopSolutions.NopCommerce.BusinessLogic.Messages.SendQueuedMessagesTask, Nop.BusinessLogic" enabled="true" stopOnError="false" maxTries="5"/>
<task name="KeepAlive" type="NopSolutions.NopCommerce.BusinessLogic.Utils.KeepAliveTask, Nop.BusinessLogic" enabled="true" stopOnError="false" path="keepalive/ping.ashx"/>
</Thread>
<Thread seconds="600">
<task name="DeleteExpiredCustomerSessions" type="NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.DeleteExpiredCustomerSessionsTask, Nop.BusinessLogic" enabled="true" stopOnError="false" deleteExpiredCustomerSessionsOlderThanMinutes="43200"/>
<task name="DeleteExpiredShoppingCarts" type="NopSolutions.NopCommerce.BusinessLogic.Orders.DeleteExpiredShoppingCartsTask, Nop.BusinessLogic" enabled="false" stopOnError="false" deleteExpiredShoppingCartsOlderThanMinutes="259200"/>
</Thread>
<Thread seconds="60">
<task name="UpdateExchangeRates" type="NopSolutions.NopCommerce.BusinessLogic.Directory.ExchangeRates.UpdateExchangeRateTask, Nop.BusinessLogic" enabled="true" stopOnError="false"/>
</Thread>
<Thread seconds="3600">
<task name="DatabaseMaintance" type="NopSolutions.NopCommerce.BusinessLogic.Maintenance.DatabaseMaintanceTask, Nop.BusinessLogic" enabled="false" stopOnError="false"/>
</Thread>
</ScheduleTasks>
</NopConfig>
</configuration>
with program.cs file :
static void Main(string[] args)
{
// Code that runs on application startup
NopConfig.Init();
//initialize IoC
IoC.InitializeWith(new DependencyResolverFactory());
//initialize task manager
TaskManager.Instance.Initialize(NopConfig.ScheduleTasks);
TaskManager.Instance.Start();
new form1().show();
TaskManager.Instance.Stop();
}

Resources