Şu anda Azure Mobile Apps kullanan uygulamam için bir arka uç çözümüm var. Facebook, twitter, google ve Microsoft girişlerini etkinleştirdim. Buna ek olarak özel bir giriş akışı eklemeyi deniyorum. Bir Auth0 hesabı ve uygulaması oluşturdum ve auth0 kilidi widget'ını kullanarak uygulama içi istekte bulunduğumda bir jetonu ve auth0'dan profil alabiliyorum. Azure mobil uygulamalar Cordova ile özel kimlik doğrulama
Ben bu kılavuzu takip: https://shellmonger.com/2016/04/08/30-days-of-zumo-v2-azure-mobile-apps-day-5-custom-authentication/ ve sahne 'Server Custom JWT Doğrulama' lazım ama bu takılıp nerede olduğunu ... benim arka uç değil node.js yüzden eşdeğer yapmalıyım nasıl C# olduğu Bu öğretici ve JWT belirteci doğrulamak ve daha sonra azureClient.login/azureClient.table kullanarak benim ön uç uygulamadan tablo denetleyicileri erişmek?DÜZENLEME: Eğer @AdrianHall ile aşağıdaki yorum dizisindeki göreceğiniz gibi Tamam ı gerek kalmadan benim cordova uygulaması içinden bir kod oluşturduktan ama benim engel şimdi bunu kabul etmek hizmet almakta olduğu başarılı olmuştur değişim jetonları. Bu, yayınlanan kılavuza göre mümkündür.
Bu, şu anda auth0 için auth çağrısı yapan istemci tarafı kodumdur ve bazı istemci tarafı, bir userID almak ve yeni belirtecin bulunduğu 'currentUser' nesnesini oluşturmak için kurulur.
MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
if (string.IsNullOrEmpty(settings.HostName))
{
// This middleware is intended to be used locally for debugging. By default, HostName will
// only have a value when running in an App Service application.
app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
{
SigningKey = ConfigurationManager.AppSettings["SigningKey"],
ValidAudiences = new[] { ConfigurationManager.AppSettings["ValidAudience"] },
ValidIssuers = new[] { ConfigurationManager.AppSettings["ValidIssuer"] },
TokenHandler = config.GetAppServiceTokenHandler()
});
}
app.UseAppServiceAuthentication
çağrı yapılandırma kurar:
auth0.lock.show(auth0.options, function(err, profile, token) {
if (err) {
console.error('Error authenticating with Auth0: ', err);
alert(err);
} else {
debugger;
var userID;
if (profile.user_id.indexOf("auth0") > -1) {
userID = profile.user_id.replace("auth0|", "");
} else if (profile.user_id.indexOf("facebook") > -1) {
userID = profile.user_id.replace("facebook|", "");
} else if (profile.user_id.indexOf("twitter") > -1) {
userID = profile.user_id.replace("twitter|", "");
} else if (profile.user_id.indexOf("microsoft") > -1) {
userID = profile.user_id.replace("microsoft|", "");
} else if (profile.user_id.indexOf("google-oauth2") > -1) {
userID = profile.user_id.replace("google-oauth2|", "");
}
window.azureClient.currentUser = {
userId: userID,
profile: profile,
mobileServiceAuthenticationToken: token
};
//A client session has now been created which contains attributes relevant to the currently logged in user.
console.log("window.azureClient.currentUser", window.azureClient.currentUser);
window.localStorage.setItem("currentUser", JSON.stringify(window.azureClient.currentUser));
//Call the get profile function which will call our API to get the user's activities and bio etc.
getProfile();
}
arka uç kodu MobileAppSettingsDictionary Azure Mobil Uygulamaları C# arka uç olarak
settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings();
if (string.IsNullOrEmpty(settings.HostName))
{
//This middleware is intended to be used locally for debugging.By default, HostName will
//only have a value when running in an App Service application.
app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions
{
SigningKey = ConfigurationManager.AppSettings[""],
ValidAudiences = new[] { ConfigurationManager.AppSettings[""] },
ValidIssuers = new[] { ConfigurationManager.AppSettings["https://domain.eu.auth0.com/"] },
TokenHandler = config.GetAppServiceTokenHandler()
});
}
Düzenleme için teşekkürler. Utanç için bir cevap veremediğin için utanmalısın. – anthonyhumphreys