-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port SSO changes from C# to JS (#1738)
* initial commit for sso (most changes) * add documentation comments * added null checks. hooked up teams * started adding tests * test case passes * mostly final changes before pr * merge with master * address comments * fix merge conflicts * addressed comments * fix some broken tests (2 remaining) * bugs during e2e testing.Also remove invalid testcase. * add accidentally reverted change. fix tests. merge with another c# pr * address merge conflicts * apply PR feedback and minor cleanup Co-authored-by: Swagat Mishra <swagatm@microsoft.com> Co-authored-by: stevengum <14935595+stevengum@users.noreply.github.com>
- Loading branch information
1 parent
3d05f87
commit 7f6c6df
Showing
31 changed files
with
1,315 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
libraries/botbuilder-core/src/extendedUserTokenProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
import { AppCredentials } from './appCredentials'; | ||
import { IUserTokenProvider } from './userTokenProvider'; | ||
import { TurnContext } from './turnContext'; | ||
import { SignInUrlResponse ,TokenResponse, TokenExchangeRequest } from 'botframework-schema'; | ||
|
||
/** | ||
* Interface for User Token OAuth Single Sign On and Token Exchange APIs for BotAdapters | ||
*/ | ||
export interface ExtendedUserTokenProvider extends IUserTokenProvider { | ||
/** | ||
* Retrieves the OAuth token for a user that is in a sign-in flow. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param magicCode (Optional) Optional user entered code to validate. | ||
*/ | ||
getUserToken(context: TurnContext, connectionName: string, magicCode?: string, appCredentials?: AppCredentials): Promise<TokenResponse>; | ||
|
||
/** | ||
* Signs the user out with the token server. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param userId User id of user to sign out. | ||
* @param oAuthAppCredentials AppCredentials for OAuth. | ||
*/ | ||
signOutUser(context: TurnContext, connectionName: string, userId?: string, appCredentials?: AppCredentials): Promise<void>; | ||
|
||
/** | ||
* Gets a signin link from the token server that can be sent as part of a SigninCard. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param oAuthAppCredentials AppCredentials for OAuth. | ||
*/ | ||
getSignInLink(context: TurnContext, connectionName: string, appCredentials?: AppCredentials): Promise<string>; | ||
|
||
/** | ||
* Signs the user out with the token server. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param oAuthAppCredentials AppCredentials for OAuth. | ||
*/ | ||
getAadTokens(context: TurnContext, connectionName: string, resourceUrls: string[], appCredentials?: AppCredentials): Promise<{ | ||
[propertyName: string]: TokenResponse; | ||
}>; | ||
|
||
/** | ||
* Get the raw signin resource to be sent to the user for signin for a connection name. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
*/ | ||
getSignInResource(context: TurnContext, connectionName: string): Promise<SignInUrlResponse>; | ||
|
||
/** | ||
* Get the raw signin resource to be sent to the user for signin for a connection name. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param userId The user id that will be associated with the token. | ||
* @param finalRedirect The final URL that the OAuth flow will redirect to. | ||
*/ | ||
getSignInResource(context: TurnContext, connectionName: string, userId: string, finalRedirect?: string): Promise<SignInUrlResponse>; | ||
|
||
/** | ||
* Get the raw signin resource to be sent to the user for signin for a connection name. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param userId The user id that will be associated with the token. | ||
* @param finalRedirect The final URL that the OAuth flow will redirect to. | ||
*/ | ||
getSignInResource(context: TurnContext, connectionName: string, userId: string, finalRedirect?: string, appCredentials?: AppCredentials): Promise<SignInUrlResponse>; | ||
|
||
/** | ||
* Performs a token exchange operation such as for single sign-on. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param userId The user id that will be associated with the token. | ||
* @param tokenExchangeRequest The exchange request details, either a token to exchange or a uri to exchange. | ||
*/ | ||
exchangeToken(context: TurnContext, connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest): Promise<TokenResponse>; | ||
|
||
/** | ||
* Performs a token exchange operation such as for single sign-on. | ||
* @param context Context for the current turn of conversation with the user. | ||
* @param connectionName Name of the auth connection to use. | ||
* @param userId The user id that will be associated with the token. | ||
* @param tokenExchangeRequest The exchange request details, either a token to exchange or a uri to exchange. | ||
*/ | ||
exchangeToken(context: TurnContext, connectionName: string, userId: string, tokenExchangeRequest: TokenExchangeRequest, appCredentials: AppCredentials): Promise<TokenResponse>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
export const verifyStateOperationName: string = 'signin/verifyState'; | ||
export const tokenExchangeOperationName: string = 'signin/tokenExchange'; | ||
export const tokenResponseEventName: string = 'tokens/response'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @module botbuilder | ||
*/ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
export enum StatusCodes { | ||
OK = 200, | ||
BAD_REQUEST = 400, | ||
UNAUTHORIZED = 401, | ||
NOT_FOUND = 404, | ||
METHOD_NOT_ALLOWED = 405, | ||
CONFLICT = 409, | ||
UPGRADE_REQUIRED = 426, | ||
INTERNAL_SERVER_ERROR = 500, | ||
NOT_IMPLEMENTED = 501, | ||
BAD_GATEWAY = 502 | ||
} |
Oops, something went wrong.