Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
348e2b4c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
348e2b4c
编写于
7月 06, 2020
作者:
R
Rachel Macfarlane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
displayName -> label, use providerIds in favor of getProviderIds, #100993
上级
1728c5ba
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
57 addition
and
36 deletion
+57
-36
extensions/github-authentication/src/github.ts
extensions/github-authentication/src/github.ts
+6
-3
extensions/microsoft-authentication/src/AADHelper.ts
extensions/microsoft-authentication/src/AADHelper.ts
+5
-4
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+1
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-2
src/vs/workbench/api/browser/mainThreadAuthentication.ts
src/vs/workbench/api/browser/mainThreadAuthentication.ts
+10
-10
src/vs/workbench/api/common/extHostAuthentication.ts
src/vs/workbench/api/common/extHostAuthentication.ts
+25
-8
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+1
-1
src/vs/workbench/browser/parts/activitybar/activitybarActions.ts
...workbench/browser/parts/activitybar/activitybarActions.ts
+2
-2
src/vs/workbench/contrib/url/browser/trustedDomains.ts
src/vs/workbench/contrib/url/browser/trustedDomains.ts
+1
-1
src/vs/workbench/services/authentication/browser/authenticationService.ts
.../services/authentication/browser/authenticationService.ts
+2
-2
src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts
...ices/userDataSync/browser/userDataSyncWorkbenchService.ts
+2
-2
未找到文件。
extensions/github-authentication/src/github.ts
浏览文件 @
348e2b4c
...
...
@@ -14,7 +14,8 @@ export const onDidChangeSessions = new vscode.EventEmitter<vscode.Authentication
interface
SessionData
{
id
:
string
;
account
?:
{
displayName
:
string
;
label
?:
string
;
displayName
?:
string
;
id
:
string
;
}
scopes
:
string
[];
...
...
@@ -95,7 +96,9 @@ export class GitHubAuthenticationProvider {
return
{
id
:
session
.
id
,
account
:
{
displayName
:
session
.
account
?.
displayName
??
userInfo
!
.
accountName
,
label
:
session
.
account
?
session
.
account
.
label
||
session
.
account
.
displayName
!
:
userInfo
!
.
accountName
,
id
:
session
.
account
?.
id
??
userInfo
!
.
id
},
scopes
:
session
.
scopes
,
...
...
@@ -138,7 +141,7 @@ export class GitHubAuthenticationProvider {
private
async
tokenToSession
(
token
:
string
,
scopes
:
string
[]):
Promise
<
vscode
.
AuthenticationSession
>
{
const
userInfo
=
await
this
.
_githubServer
.
getUserInfo
(
token
);
return
new
vscode
.
AuthenticationSession
(
uuid
(),
token
,
{
displayName
:
userInfo
.
accountName
,
id
:
userInfo
.
id
},
scopes
);
return
new
vscode
.
AuthenticationSession
(
uuid
(),
token
,
{
label
:
userInfo
.
accountName
,
id
:
userInfo
.
id
},
scopes
);
}
private
async
setToken
(
session
:
vscode
.
AuthenticationSession
):
Promise
<
void
>
{
...
...
extensions/microsoft-authentication/src/AADHelper.ts
浏览文件 @
348e2b4c
...
...
@@ -26,7 +26,7 @@ interface IToken {
refreshToken
:
string
;
account
:
{
displayName
:
string
;
label
:
string
;
id
:
string
;
};
scope
:
string
;
...
...
@@ -48,7 +48,8 @@ interface IStoredSession {
refreshToken
:
string
;
scope
:
string
;
// Scopes are alphabetized and joined with a space
account
:
{
displayName
:
string
,
label
?:
string
;
displayName
?:
string
,
id
:
string
}
}
...
...
@@ -101,7 +102,7 @@ export class AzureActiveDirectoryService {
accessToken
:
undefined
,
refreshToken
:
session
.
refreshToken
,
account
:
{
displayName
:
session
.
account
.
displayName
,
label
:
session
.
account
.
label
??
session
.
account
.
displayName
!
,
id
:
session
.
account
.
id
},
scope
:
session
.
scope
,
...
...
@@ -437,7 +438,7 @@ export class AzureActiveDirectoryService {
scope
,
sessionId
:
existingId
||
`
${
claims
.
tid
}
/
${(
claims
.
oid
||
(
claims
.
altsecid
||
''
+
claims
.
ipd
||
''
))}
/
${
uuid
()}
`
,
account
:
{
displayName
:
claims
.
email
||
claims
.
unique_name
||
'
user@example.com
'
,
label
:
claims
.
email
||
claims
.
unique_name
||
'
user@example.com
'
,
id
:
`
${
claims
.
tid
}
/
${(
claims
.
oid
||
(
claims
.
altsecid
||
''
+
claims
.
ipd
||
''
))}
`
}
};
...
...
src/vs/editor/common/modes.ts
浏览文件 @
348e2b4c
...
...
@@ -1413,7 +1413,7 @@ export interface AuthenticationSession {
id
:
string
;
accessToken
:
string
;
account
:
{
displayName
:
string
;
label
:
string
;
id
:
string
;
}
scopes
:
ReadonlyArray
<
string
>
;
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
348e2b4c
...
...
@@ -52,7 +52,7 @@ declare module 'vscode' {
/**
* The human-readable name of the account.
*/
readonly
displayName
:
string
;
readonly
label
:
string
;
/**
* The unique identifier of the account.
...
...
@@ -175,13 +175,13 @@ declare module 'vscode' {
export
const
onDidChangeAuthenticationProviders
:
Event
<
AuthenticationProvidersChangeEvent
>
;
/**
* @deprecated
* The ids of the currently registered authentication providers.
* @returns An array of the ids of authentication providers that are currently registered.
*/
export
function
getProviderIds
():
Thenable
<
ReadonlyArray
<
string
>>
;
/**
* @deprecated
* An array of the ids of authentication providers that are currently registered.
*/
export
const
providerIds
:
ReadonlyArray
<
string
>
;
...
...
src/vs/workbench/api/browser/mainThreadAuthentication.ts
浏览文件 @
348e2b4c
...
...
@@ -135,17 +135,17 @@ export class MainThreadAuthenticationProvider extends Disposable {
}
private
registerSession
(
session
:
modes
.
AuthenticationSession
)
{
this
.
_sessions
.
set
(
session
.
id
,
session
.
account
.
displayName
);
this
.
_sessions
.
set
(
session
.
id
,
session
.
account
.
label
);
const
existingSessionsForAccount
=
this
.
_accounts
.
get
(
session
.
account
.
displayName
);
const
existingSessionsForAccount
=
this
.
_accounts
.
get
(
session
.
account
.
label
);
if
(
existingSessionsForAccount
)
{
this
.
_accounts
.
set
(
session
.
account
.
displayName
,
existingSessionsForAccount
.
concat
(
session
.
id
));
this
.
_accounts
.
set
(
session
.
account
.
label
,
existingSessionsForAccount
.
concat
(
session
.
id
));
return
;
}
else
{
this
.
_accounts
.
set
(
session
.
account
.
displayName
,
[
session
.
id
]);
this
.
_accounts
.
set
(
session
.
account
.
label
,
[
session
.
id
]);
}
this
.
storageKeysSyncRegistryService
.
registerStorageKey
({
key
:
`
${
this
.
id
}
-
${
session
.
account
.
displayName
}
`
,
version
:
1
});
this
.
storageKeysSyncRegistryService
.
registerStorageKey
({
key
:
`
${
this
.
id
}
-
${
session
.
account
.
label
}
`
,
version
:
1
});
}
async
signOut
(
accountName
:
string
):
Promise
<
void
>
{
...
...
@@ -273,7 +273,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
if
(
sessions
.
length
)
{
if
(
!
this
.
authenticationService
.
supportsMultipleAccounts
(
providerId
))
{
const
session
=
sessions
[
0
];
const
allowed
=
await
this
.
$getSessionsPrompt
(
providerId
,
session
.
account
.
displayName
,
label
,
extensionId
,
extensionName
);
const
allowed
=
await
this
.
$getSessionsPrompt
(
providerId
,
session
.
account
.
label
,
label
,
extensionId
,
extensionName
);
if
(
allowed
)
{
return
session
;
}
else
{
...
...
@@ -292,7 +292,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
}
const
session
=
await
this
.
authenticationService
.
login
(
providerId
,
scopes
);
await
this
.
$setTrustedExtension
(
providerId
,
session
.
account
.
displayName
,
extensionId
,
extensionName
);
await
this
.
$setTrustedExtension
(
providerId
,
session
.
account
.
label
,
extensionId
,
extensionName
);
return
session
;
}
else
{
await
this
.
$requestNewSession
(
providerId
,
scopes
,
extensionId
,
extensionName
);
...
...
@@ -313,7 +313,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
if
(
existingSessionPreference
)
{
const
matchingSession
=
potentialSessions
.
find
(
session
=>
session
.
id
===
existingSessionPreference
);
if
(
matchingSession
)
{
const
allowed
=
await
this
.
$getSessionsPrompt
(
providerId
,
matchingSession
.
account
.
displayName
,
providerName
,
extensionId
,
extensionName
);
const
allowed
=
await
this
.
$getSessionsPrompt
(
providerId
,
matchingSession
.
account
.
label
,
providerName
,
extensionId
,
extensionName
);
if
(
allowed
)
{
return
matchingSession
;
}
...
...
@@ -326,7 +326,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
quickPick
.
ignoreFocusOut
=
true
;
const
items
:
{
label
:
string
,
session
?:
modes
.
AuthenticationSession
}[]
=
potentialSessions
.
map
(
session
=>
{
return
{
label
:
session
.
account
.
displayName
,
label
:
session
.
account
.
label
,
session
};
});
...
...
@@ -351,7 +351,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
const
session
=
selected
.
session
??
await
this
.
authenticationService
.
login
(
providerId
,
scopes
);
const
accountName
=
session
.
account
.
displayName
;
const
accountName
=
session
.
account
.
label
;
const
allowList
=
readAllowedExtensions
(
this
.
storageService
,
providerId
,
accountName
);
if
(
!
allowList
.
find
(
allowed
=>
allowed
.
id
===
extensionId
))
{
...
...
src/vs/workbench/api/common/extHostAuthentication.ts
浏览文件 @
348e2b4c
...
...
@@ -14,6 +14,8 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
private
_proxy
:
MainThreadAuthenticationShape
;
private
_authenticationProviders
:
Map
<
string
,
vscode
.
AuthenticationProvider
>
=
new
Map
<
string
,
vscode
.
AuthenticationProvider
>
();
private
_providerIds
:
string
[]
=
[];
private
_onDidChangeAuthenticationProviders
=
new
Emitter
<
vscode
.
AuthenticationProvidersChangeEvent
>
();
readonly
onDidChangeAuthenticationProviders
:
Event
<
vscode
.
AuthenticationProvidersChangeEvent
>
=
this
.
_onDidChangeAuthenticationProviders
.
event
;
...
...
@@ -29,12 +31,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
}
get
providerIds
():
string
[]
{
const
ids
:
string
[]
=
[];
this
.
_authenticationProviders
.
forEach
(
provider
=>
{
ids
.
push
(
provider
.
id
);
});
return
ids
;
return
this
.
_providerIds
;
}
private
async
resolveSessions
(
providerId
:
string
):
Promise
<
ReadonlyArray
<
modes
.
AuthenticationSession
>>
{
...
...
@@ -72,7 +69,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
if
(
sessions
.
length
)
{
if
(
!
provider
.
supportsMultipleAccounts
)
{
const
session
=
sessions
[
0
];
const
allowed
=
await
this
.
_proxy
.
$getSessionsPrompt
(
providerId
,
session
.
account
.
displayName
,
provider
.
label
,
extensionId
,
extensionName
);
const
allowed
=
await
this
.
_proxy
.
$getSessionsPrompt
(
providerId
,
session
.
account
.
label
,
provider
.
label
,
extensionId
,
extensionName
);
if
(
allowed
)
{
return
session
;
}
else
{
...
...
@@ -91,7 +88,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
}
const
session
=
await
provider
.
login
(
scopes
);
await
this
.
_proxy
.
$setTrustedExtension
(
providerId
,
session
.
account
.
displayName
,
extensionId
,
extensionName
);
await
this
.
_proxy
.
$setTrustedExtension
(
providerId
,
session
.
account
.
label
,
extensionId
,
extensionName
);
return
session
;
}
else
{
await
this
.
_proxy
.
$requestNewSession
(
providerId
,
scopes
,
extensionId
,
extensionName
);
...
...
@@ -115,6 +112,9 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
}
this
.
_authenticationProviders
.
set
(
provider
.
id
,
provider
);
if
(
!
this
.
_providerIds
.
includes
(
provider
.
id
))
{
this
.
_providerIds
.
push
(
provider
.
id
);
}
const
listener
=
provider
.
onDidChangeSessions
(
e
=>
{
this
.
_proxy
.
$sendDidChangeSessions
(
provider
.
id
,
e
);
...
...
@@ -125,6 +125,10 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
return
new
Disposable
(()
=>
{
listener
.
dispose
();
this
.
_authenticationProviders
.
delete
(
provider
.
id
);
const
index
=
this
.
_providerIds
.
findIndex
(
id
=>
id
===
provider
.
id
);
if
(
index
>
-
1
)
{
this
.
_providerIds
.
splice
(
index
);
}
this
.
_proxy
.
$unregisterAuthenticationProvider
(
provider
.
id
);
});
}
...
...
@@ -177,6 +181,19 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
}
$onDidChangeAuthenticationProviders
(
added
:
string
[],
removed
:
string
[])
{
added
.
forEach
(
id
=>
{
if
(
!
this
.
_providerIds
.
includes
(
id
))
{
this
.
_providerIds
.
push
(
id
);
}
});
removed
.
forEach
(
id
=>
{
const
index
=
this
.
_providerIds
.
findIndex
(
provider
=>
provider
===
id
);
if
(
index
>
-
1
)
{
this
.
_providerIds
.
splice
(
index
);
}
});
this
.
_onDidChangeAuthenticationProviders
.
fire
({
added
,
removed
});
return
Promise
.
resolve
();
}
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
348e2b4c
...
...
@@ -2770,7 +2770,7 @@ export enum ExtensionMode {
//#region Authentication
export
class
AuthenticationSession
implements
vscode
.
AuthenticationSession
{
constructor
(
public
id
:
string
,
public
accessToken
:
string
,
public
account
:
{
displayName
:
string
,
id
:
string
},
public
scopes
:
string
[])
{
}
constructor
(
public
id
:
string
,
public
accessToken
:
string
,
public
account
:
{
label
:
string
,
id
:
string
},
public
scopes
:
string
[])
{
}
}
//#endregion Authentication
...
...
src/vs/workbench/browser/parts/activitybar/activitybarActions.ts
浏览文件 @
348e2b4c
...
...
@@ -141,7 +141,7 @@ export class AccountsActionViewItem extends ActivityActionViewItem {
const
providers
=
this
.
authenticationService
.
getProviderIds
();
const
allSessions
=
providers
.
map
(
async
id
=>
{
const
sessions
=
await
this
.
authenticationService
.
getSessions
(
id
);
const
uniqueSessions
=
distinct
(
sessions
,
session
=>
session
.
account
.
displayName
);
const
uniqueSessions
=
distinct
(
sessions
,
session
=>
session
.
account
.
label
);
return
{
providerId
:
id
,
sessions
:
uniqueSessions
...
...
@@ -153,7 +153,7 @@ export class AccountsActionViewItem extends ActivityActionViewItem {
result
.
forEach
(
sessionInfo
=>
{
const
providerDisplayName
=
this
.
authenticationService
.
getLabel
(
sessionInfo
.
providerId
);
sessionInfo
.
sessions
.
forEach
(
session
=>
{
const
accountName
=
session
.
account
.
displayName
;
const
accountName
=
session
.
account
.
label
;
const
menu
=
new
ContextSubMenu
(
`
${
accountName
}
(
${
providerDisplayName
}
)`
,
[
new
Action
(
`configureSessions
${
accountName
}
`
,
nls
.
localize
(
'
manageTrustedExtensions
'
,
"
Manage Trusted Extensions
"
),
''
,
true
,
_
=>
{
return
this
.
authenticationService
.
manageTrustedExtensionsForAccount
(
sessionInfo
.
providerId
,
accountName
);
...
...
src/vs/workbench/contrib/url/browser/trustedDomains.ts
浏览文件 @
348e2b4c
...
...
@@ -185,7 +185,7 @@ export async function readTrustedDomains(accessor: ServicesAccessor) {
const
userDomains
=
authenticationService
.
isAuthenticationProviderRegistered
(
'
github
'
)
?
((
await
authenticationService
.
getSessions
(
'
github
'
))
??
[])
.
map
(
session
=>
session
.
account
.
displayName
)
.
map
(
session
=>
session
.
account
.
label
)
.
filter
((
v
,
i
,
a
)
=>
a
.
indexOf
(
v
)
===
i
)
.
map
(
username
=>
`https://github.com/
${
username
}
/`
)
:
[];
...
...
src/vs/workbench/services/authentication/browser/authenticationService.ts
浏览文件 @
348e2b4c
...
...
@@ -255,10 +255,10 @@ export class AuthenticationService extends Disposable implements IAuthentication
const
session
=
await
authenticationService
.
login
(
providerId
,
scopes
);
// Add extension to allow list since user explicitly signed in on behalf of it
const
allowList
=
readAllowedExtensions
(
storageService
,
providerId
,
session
.
account
.
displayName
);
const
allowList
=
readAllowedExtensions
(
storageService
,
providerId
,
session
.
account
.
label
);
if
(
!
allowList
.
find
(
allowed
=>
allowed
.
id
===
extensionId
))
{
allowList
.
push
({
id
:
extensionId
,
name
:
extensionName
});
storageService
.
store
(
`
${
providerId
}
-
${
session
.
account
.
displayName
}
`
,
JSON
.
stringify
(
allowList
),
StorageScope
.
GLOBAL
);
storageService
.
store
(
`
${
providerId
}
-
${
session
.
account
.
label
}
`
,
JSON
.
stringify
(
allowList
),
StorageScope
.
GLOBAL
);
}
// And also set it as the preferred account for the extension
...
...
src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts
浏览文件 @
348e2b4c
...
...
@@ -49,7 +49,7 @@ class UserDataSyncAccount implements IUserDataSyncAccount {
constructor
(
readonly
authenticationProviderId
:
string
,
private
readonly
session
:
AuthenticationSession
)
{
}
get
sessionId
():
string
{
return
this
.
session
.
id
;
}
get
accountName
():
string
{
return
this
.
session
.
account
.
displayName
;
}
get
accountName
():
string
{
return
this
.
session
.
account
.
label
;
}
get
accountId
():
string
{
return
this
.
session
.
account
.
id
;
}
get
token
():
string
{
return
this
.
session
.
accessToken
;
}
}
...
...
@@ -305,7 +305,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
if
(
isAuthenticationProvider
(
result
))
{
const
session
=
await
this
.
authenticationService
.
login
(
result
.
id
,
result
.
scopes
);
sessionId
=
session
.
id
;
accountName
=
session
.
account
.
displayName
;
accountName
=
session
.
account
.
label
;
accountId
=
session
.
account
.
id
;
}
else
{
sessionId
=
result
.
sessionId
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录