Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export enum BotStatus {

export type BotEnvironments = 'production' | 'integration' | 'editing';

export interface AuthenticatedToken {
accessToken: string;
deocdedToken?: AuthenticatedUser;
}

export interface AuthenticatedUser {
[ClaimNames.name]: string;
[ClaimNames.upn]: string;
Expand All @@ -18,7 +23,7 @@ export interface BotConfig {
MicrosoftAppPassword: string;
luis: ILuisConfig;
targetEnvironment?: BotEnvironments;
user?: AuthenticatedUser;
user?: AuthenticatedToken;
}

export interface IBotConnector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ export class SelfHostBotConnector implements IBotConnector {

public sync = async (config: BotConfig) => {
const { targetEnvironment: env } = config;
const user = config.user ? config.user[ClaimNames.name] : 'unknown_user';
const userEmail = config.user ? config.user[ClaimNames.upn] : undefined;
const user = config.user && config.user.deocdedToken ? config.user.deocdedToken[ClaimNames.name] : 'unknown_user';
const userEmail = config.user && config.user.deocdedToken ? config.user.deocdedToken[ClaimNames.upn] : undefined;
const accessToken = config.user ? config.user.accessToken : undefined;
await this.buildAsync({
user,
userEmail,
//eslint-disable-next-line @typescript-eslint/no-non-null-assertion
dest: resolve(process.env.HOME!, 'site/artifacts/bot'),
env: env && env !== 'editing' ? env : 'integration',
botId: undefined,
accessToken,
});
};
}
5 changes: 4 additions & 1 deletion Composer/packages/server/src/router/absh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ const absh: AuthProviderInit = {
return;
}

req.user = token;
req.user = {
decodedToken: token,
accessToken: bearer,
};
next();
});
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/server/types/selfHostCommands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare namespace SelfHostCommands {
userEmail?: string;
env: 'production' | 'integration';
dest: string;
accessToken: string | undefined;
botId: string | undefined;
}
export interface Build {
(argv: ARGV): Promise<string>;
Expand Down