review fixes

This commit is contained in:
Raghunandan
2020-06-18 13:55:03 +02:00
parent efd632d9ce
commit b421ba6b8d
5 changed files with 21 additions and 9 deletions
@@ -158,14 +158,14 @@ export type ProfileInfoOptions = {
};
/**
* This API provides access to profile information of the signed in user.
* This API provides access to profile information of the user from an auth provider.
*/
export type ProfileInfoApi = {
getProfile(options?: ProfileInfoOptions): Promise<ProfileInfo | undefined>;
};
/**
* Profile information of a signed in user.
* Profile information of the user from an auth provider.
*/
export type ProfileInfo = {
/**
@@ -57,6 +57,8 @@ export class EnvironmentHandler implements AuthProviderRouteHandlers {
async logout(req: express.Request, res: express.Response): Promise<void> {
const provider = this.getProviderForEnv(req);
await provider.logout(req, res);
if (provider.logout) {
await provider.logout(req, res);
}
}
}
@@ -21,6 +21,7 @@ import {
RedirectInfo,
RefreshTokenResponse,
ProfileInfo,
ProviderStrategy,
} from '../providers/types';
export const makeProfileInfo = (
@@ -153,7 +154,7 @@ export const executeFetchUserProfileStrategy = async (
params: any,
): Promise<ProfileInfo> => {
return new Promise((resolve, reject) => {
const anyStrategy = providerStrategy as any;
const anyStrategy = (providerStrategy as unknown) as ProviderStrategy;
anyStrategy.userProfile(
accessToken,
(error: Error, passportProfile: passport.Profile) => {
@@ -44,7 +44,9 @@ export const createAuthProviderRouter = (
router.get('/start', provider.start.bind(provider));
router.get('/handler/frame', provider.frameHandler.bind(provider));
router.post('/handler/frame', provider.frameHandler.bind(provider));
router.post('/logout', provider.logout.bind(provider));
if (provider.logout) {
router.post('/logout', provider.logout.bind(provider));
}
if (provider.refresh) {
router.get('/refresh', provider.refresh.bind(provider));
}
+11 -4
View File
@@ -34,12 +34,15 @@ export type OAuthProviderOptions = {
export type OAuthProviderConfig = {
/**
* If the cookies set by the provider have to be marked secure. For development environment
* we don't mark the cookie as secure.
* Cookies can be marked with a secure flag to send cookies only when the request
* is over an encrypted channel (HTTPS).
*
* For development environment we don't mark the cookie as secure since we serve
* localhost over HTTP.
*/
secure: boolean;
/**
* The domain:port where the app (frontend) is hosted. This is used to post messages back
* The protocol://domain[:port] where the app (frontend) is hosted. This is used to post messages back
* to the window that initiates an auth request.
*/
appOrigin: string;
@@ -68,7 +71,7 @@ export type EnvironmentProviderConfig = {
export type AuthProviderConfig = {
/**
* The domain:port where the app is hosted. This is used to construct the
* The protocol://domain[:port] where the app is hosted. This is used to construct the
* callbackURL to redirect to once the user signs in to the auth provider.
*/
baseUrl: string;
@@ -261,6 +264,10 @@ export type RefreshTokenResponse = {
params: any;
};
export type ProviderStrategy = {
userProfile(accessToken: string, callback: Function): void;
};
export type SAMLProviderConfig = {
entryPoint: string;
issuer: string;