OAuth google connection in ASP.NET MVC - asp.net-mvc

I was searching google a lot these days but I couldn't found proper solution.
In my ASP.NET MVC application I want to use external log in so that the users can log via their google accounts. At first at localhost in AuthConfig.cs file I used:
OAuthWebSecurity.RegisterGoogleClient();
Then when moving on the server I got the error:
So I found a lot of links leading to creating a project on this link and I created one, but I still can not figure out where and how to add the credentials. In my AuthConfig.cs file I have this structure so far:
public static void RegisterAuth()
{
//OAuthWebSecurity.RegisterGoogleClient();
}
and I can not use the format that starts with (I found this i a few places):
app.UseGoogleAuthentication(
clientId: "000-000.apps.googleusercontent.com",
clientSecret: "00000000000");
because that app is not part of my file at all. Can anyone give me a direction how I should continue?

The new OWIN/ASP.NET Identity looks good. I also tried the walk through that DSR mentioned, it is pretty easy.
You can take a look at:
http://www.asp.net/identity
Which has a link to the good walk through about OAuth mentioned in the comments, but also this one, about adding Identity to an existing project:
http://www.asp.net/identity/overview/getting-started/adding-aspnet-identity-to-an-empty-or-existing-web-forms-project

Related

SimpleSAMLphp as idp : Metadata not found

I am working on SSO authentification system using SAML2 protocol. Since i do not have the real IDP informations yet, i needed test environment so i used this docker image which worked like a charm. I am able to access it through localhost:8080 without any problem and also to log in with test account.
But then, when i try to log into my SP (the website i am working on), though i am well redirected to the idp at localhost:8080/simplesaml/saml2/idp/SSOService.php, i got an error telling me metadata not found. here is the stack trace :
SimpleSAML_Error_MetadataNotFound: METADATANOTFOUND('%ENTITYID%' => '\'\'')
Backtrace:
3 lib/SimpleSAML/Metadata/MetaDataStorageHandler.php:300 (SimpleSAML_Metadata_MetaDataStorageHandler::getMetaData)
2 lib/SimpleSAML/Metadata/MetaDataStorageHandler.php:320 (SimpleSAML_Metadata_MetaDataStorageHandler::getMetaDataConfig)
1 modules/saml/lib/IdP/SAML2.php:330 (sspmod_saml_IdP_SAML2::receiveAuthnRequest)
0 www/saml2/idp/SSOService.php:19 (N/A)
Did anybody ever faced the same one ? Because i don't really understand where SimpleSAMLphp try to get those metadata.
NOTE :
I am manually able to find metadata at localhost:8080/simplesaml/saml2/idp/metadata.php
It is an old project i am working for and it is a fork of symfony 1 so i can't use more recent plugins. So for SSO i use this plugin on service provider side.
Finally solved. The Authn Request i sent contained empty "issuer" field and this one was needed on idp side since simpleSAMLphp seemes to store SP Metadata in an array like Metdata['spName']. So of course their was no entry for the empty string as key.

Power BI embedded Issue

I am trying to integrate the power bi report with our asp.net mvc application. So I found this https://azure.microsoft.com/en-us/documentation/articles/power-bi-embedded-get-started-sample/ article and followed the steps. I have successfully created the workspace collection and generated the access keys. And I downloaded this https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/ sample application as specified in the article and ran the ProvisionSample contsole application. I selected the 5th step and provided the appropriate values for workspace collection name and access key and it throws the following error "Operation returned an invalid status code 'Forbidden'". I looked at the audit logs and there is no error. Anyone have idea what causes for this issue?
There is an issue going on right now that is effecting some parts of the world. We are actively working on a fix.

No valid key mapping found for securityToken

I am developing test application for displaying claims of authenticated identity in MVC-ASP.net (Visual studio 2013)
I have given authentication from active directory in following way.
1.Add new mvc project in solution .
2.click on Change authentication.
3.select organization account
4.select on premises.
5.given federation url
6.App Id url
After running the application i am getting following error.
WIF10201: No valid key mapping found for securityToken: 'System.IdentityModel.Tokens.X509SecurityToken' and issuer: 'http://websso.avanade.com/adfs/services/trust'
This error is coming only for this federation for other federation i am able to see claims.
After searching on internet i am thinking that it is certificate(thumbprint) issue.
But I am not clear with solutions.
Can anybody explain me why this error throwing and solution for the same.
Thanks in Advance !!!
There could be 2 causes for this error.
Missing thumbprint in web.config: Get the actual thumbprint from ADFS and put in web.config under the thumbprint tag
Mismatch in port number between the site and ADFS configuration: Update ADFS configuration with the url containing the correct port number
The second solution fixed it for me...
I ran into this while trying to update a legacy MVC application to use AAD.
I based the changes on a newly created project with organizational authentication and noticed I did not have a connection string named DefaultConnection, which the DatabaseIssuerNameRegistry assumes you will, nor did I have either of the required tables in the database.
Using Vittorio Bertocci's great post with all the details, I refactored the code to integrate the new database tables, created and applied a migration, and inserted the appropriate key and tenant in the new IssuingAuthorityKey and Tenant tables, respectively. I also had to make sure to change the DatabaseIssueNameRegistry to use the existing DbContext.
For solutions created in VS2013 and later, the solution should contain the logic to roll over keys automatically. No need to put the value in the web.config file.
You might run into this issue when migrating your solution from local to another environment. In that case you will probably try to point your solution to a new application in Azure Active Directory. Check the following:
Make sure all urls in the web.config are pointing to the correct url not the one automatically generated when you set it up locally
Remove all enteries from IssuingAuthorityKeys table. The keys will autopopulate when you re-build the solution and run it. On the server you might need to replace the dlls manually for it to refresh
Last and most important, delete all rows from the Tenants table. On the first run on the new environment, an Admin from the owning Active Directory has to sign up and authorize the application.
If the values in both tables are still not populated automatically after these steps, check this article for steps on how to manually get the values.
Thumbprints and server names are case sensitive in web.config. make sure they are typed correctly and restart IIS.
It fixed my issue.

Getting Authentication working on Mono for Android with servicestack

I've got ServiceStack working nicely on the server and with a Windows test client, and now need to get it working in my Mono For Android application.
I've downloaded the following:
ServiceStack.Common.dll
ServiceStack.Interfaces.dll
ServiceStack.Text.dll
from the github tip, and added references to these in my Mono for Android project.
However, we need to use authentication, so need the ServiceStack.ServiceInterface.Web namespace to be available for the client, so I can do the following:
var c = new JsonServiceClient("http://localhost:53434");
var authResponse = c.Get(new Auth { UserName = "myusername", Password = "password", RememberMe = true });
Looking at my working test client, Auth is defined in ServiceStack.ServiceInterface.dll, so presumably I need to get hold of this DLL, or its source and compile it in my project.
Am I on the right lines here, or is there a simpler way to set things up? I've searched around but can't find a good resource on how to use ServiceStack with Mono For Android - if there is one, please feel free to point me to it!
I note this StackOverflow indicates I'm on the right lines - all I might need is ServiceStack.ServiceInterface.dll compiled for Mono For Android.
James
You shouldn't have to compile the server ServiceStack.ServiceInterface.dll for use in any client library as there is a copy of the Auth DTOs is also available in the ServiceStack.Common.dll client library at ServiceStack.Common.ServiceClient.Web.AuthDtos.cs.
This is possible since both server and client DTOs generate the same wireformat.

Google oAuth example

I'm looking for a worked example of how to call into Googles oAuth service with a view to simply uploading a txt file. On googles docs I have the followed the example
http://code.google.com/p/google-api-java-client/wiki/OAuth2
but it won't compile .... CalendarScopes.CALENDAR is the problem and I can't see what Jar contains this class. I imported every Jar in the google-oauth-java-client-1.12.0-beta download (Also every jar in google-api-java-client-1.12.0-beta ) I dobn't understand the diff between these but that is for another day.
Any pointers would be welcome.
CalendarScopes.CALENDAR that you mentioned is not a part of a jar file but a scope for Calendar API provided by Google. For a sample to show how to implement that, here is one.
In the meanwhile, I would also suggest going over the following links to develop an understanding of the OAuth and how to use it with the different APIs.
OAuth Playground - This is very helpful when trying to learn about different API and permissions relating to those.
OpenID Connect Official Documentation
Hope this helps.

Resources