Bug 1597933 - clean up OAuth2 code: remove responseType which is always "code". r=Fallen
Response type "token" is part of the OAuth 2.0 Implicit Flow which is not used in Thunderbird, but also discouraged by the OAuth Working Group: https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead
This commit is contained in:
Родитель
75816dc8f4
Коммит
6c330b5815
|
@ -3,7 +3,8 @@
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides OAuth 2.0 authentication
|
* Provides OAuth 2.0 authentication.
|
||||||
|
* @see RFC 6749
|
||||||
*/
|
*/
|
||||||
var EXPORTED_SYMBOLS = ["OAuth2"];
|
var EXPORTED_SYMBOLS = ["OAuth2"];
|
||||||
|
|
||||||
|
@ -41,7 +42,6 @@ OAuth2.CODE_AUTHORIZATION = "authorization_code";
|
||||||
OAuth2.CODE_REFRESH = "refresh_token";
|
OAuth2.CODE_REFRESH = "refresh_token";
|
||||||
|
|
||||||
OAuth2.prototype = {
|
OAuth2.prototype = {
|
||||||
responseType: "code",
|
|
||||||
consumerKey: null,
|
consumerKey: null,
|
||||||
consumerSecret: null,
|
consumerSecret: null,
|
||||||
completionURI: "http://localhost",
|
completionURI: "http://localhost",
|
||||||
|
@ -77,7 +77,7 @@ OAuth2.prototype = {
|
||||||
|
|
||||||
requestAuthorization() {
|
requestAuthorization() {
|
||||||
let params = [
|
let params = [
|
||||||
["response_type", this.responseType],
|
["response_type", "code"],
|
||||||
["client_id", this.consumerKey],
|
["client_id", this.consumerKey],
|
||||||
["redirect_uri", this.completionURI],
|
["redirect_uri", this.completionURI],
|
||||||
];
|
];
|
||||||
|
@ -186,10 +186,8 @@ OAuth2.prototype = {
|
||||||
onAuthorizationReceived(aData) {
|
onAuthorizationReceived(aData) {
|
||||||
this.log.info("authorization received" + aData);
|
this.log.info("authorization received" + aData);
|
||||||
let results = parseURLData(aData);
|
let results = parseURLData(aData);
|
||||||
if (this.responseType == "code" && results.code) {
|
if (results.code) {
|
||||||
this.requestAccessToken(results.code, OAuth2.CODE_AUTHORIZATION);
|
this.requestAccessToken(results.code, OAuth2.CODE_AUTHORIZATION);
|
||||||
} else if (this.responseType == "token") {
|
|
||||||
this.onAccessTokenReceived(JSON.stringify(results));
|
|
||||||
} else {
|
} else {
|
||||||
this.onAuthorizationFailed(null, aData);
|
this.onAuthorizationFailed(null, aData);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче