Попытка сделать тихую аутентификацию во вкладке Команды - PullRequest
0 голосов
/ 01 апреля 2019

Я установил вкладку «Команды», а также приложение Azure AD с правильными разрешениями и указал правильные URL-адреса. Я пытался следовать этому руководству

Я вижу в fiddler, что запрос сделан на мою страницу авторизации вкладок со страницы вкладок. Перед этим запрос, исходящий со страницы tab-auth, переходит по этому адресу:

https://login.microsoftonline.com/common/oauth2/authorize?response_type=id_token&client_id=xxx&redirect_uri=https%3A%2F%2Fmsteamsapp.domain.se%2Fpublic%2Ftab%2Ftabconfig%2Ftab-auth.aspx&state=xxxx&scope=openid+profile&login_hint=xxxxx&client-request-id=xxxx&x-client-SKU=Js&x-client-Ver=1.0.15&prompt=none&nonce=xxxxx

Я также получаю некоторые ошибки в консоли разработчика:

Ошибка при анализе атрибута allow: '*;' недопустимое имя объекта.

Uncaught TypeError: Невозможно прочитать свойство 'displayCall' из неопределенного на новый AuthenticationContext (adal.min.js: 2) на вкладке auth.aspx: 26

Uncaught DOMException: заблокирован кадр с источником "https://msteamsapp.domain.se" от доступа к фрейму перекрестного происхождения. при загрузке окна (https://msteamsapp.domain.se/public/tab/tabConfig/tab.aspx

adal.min.js: 2 Uncaught TypeError: Невозможно прочитать свойство 'displayCall' неопределенного на новый AuthenticationContext (adal.min.js: 2) на вкладке auth.aspx: 26

tab.aspx Имеет этот код:

        window.onload = function () {

            if (parent.document.getElementById("extension-tab-frame")) {
                var iframe = parent.document.getElementById("extension-tab-frame");
                iframe.sandbox = 'allow-forms allow-modals allow-popups allow-pointer-lock allow-scripts allow-same-origin allow-top-navigation';
            }
        }
        
        // ADAL.js configuration
        let config = {
            clientId: "xxxxxx",
            // redirectUri must be in the list of redirect URLs for the Azure AD app
            redirectUri: window.location.origin + "/public/tab/tabconfig/tab-auth.aspx",
            cacheLocation: "localStorage",
            navigateToLoginRequestUrl: true,
        };
        loginHint = 'xxxx';
        if (loginHint) {
        config.extraQueryParameter = "scope=openid+profile&login_hint=" + encodeURIComponent(loginHint);
    } else {
        config.extraQueryParameter = "scope=openid+profile";
        }
let authContext = new AuthenticationContext(config); // from the ADAL.js library
// See if there's a cached user and it matches the expected user
let user = authContext.getCachedUser();
if (user) {
    if (user.profile.oid !== userObjectId) {
        // User doesn't match, clear the cache
        authContext.clearCache();
    }
}


let token = authContext.getCachedToken(config.clientId);
if (token) {
    showProfileInformation(token);
} else {
    authContext._renewIdToken(function (err, idToken) {
        if (err) {
            console.log("Renewal failed: " + err);
            // Failed to get the token silently; show the login button
            showLoginButton();

        } else {
            showProfileInformation(idToken);
        }
    });
    }

Вкладка-Auth-ASPX имеет этот код:

let authContext = new AuthenticationContext();
                if (authContext.isCallback(window.location.hash)) {
                  authContext.handleWindowCallback(window.location.hash);
                                   if (authContext.getCachedUser()) {
                                       console.log('works');
                                        microsoftTeams.authentication.notifySuccess();
                                   } else {
                                       console.log('failure');
                                       console.log(authContext.getLoginError());
                                       microsoftTeams.authentication.notifyFailure(authContext.getLoginError());
                  }
                }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...