mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-23 16:02:14 +00:00
* start with user * user first try done in all services * user, org, idp for discussion * remove unused stuff * bla * dockerbuild * rename search, get multiple to list... * add annotation * update proto dependencies * update proto dependencies * change proto imports * replace all old imports * fix go out * remove unused lines * correct protoc flags * grpc and openapi flags * go out source path relative * -p * remove dead code * sourcepath relative * ls * is onenapi the problem? * hobla * authoption output * wrong field name * gopf * correct option, add correct flags * small improvments * SIMPLYFY * relative path * gopf bin ich en tubel * correct path * default policies in admin * grpc generation in one file * remove non ascii * metadata on manipulations * correct auth_option import * fixes * larry * idp provider to idp * fix generate * admin and auth nearly done * admin and auth nearly done * gen * healthz * imports * deleted too much imports * fix org * add import * imports * import * naming * auth_opt * gopf * management * imports * _TYPE_UNSPECIFIED * improts * auth opts * management policies * imports * passwordlessType to MFAType * auth_opt * add user grant calls * add missing messages * result * fix option * improvements * ids * fix http * imports * fixes * fields * body * add fields * remove wrong member query * fix request response * fixes * add copy files * variable versions * generate all files * improvements * add dependencies * factors * user session * oidc information, iam * remove unused file * changes * enums * dockerfile * fix build * remove unused folder * update readme for build * move old server impl * add event type to change * some changes * start admin * remove wrong field * admin only list calls missing * fix proto numbers * surprisingly it compiles * service ts changes * admin mgmt * mgmt * auth manipulation and gets done, lists missing * validations and some field changes * validations * enum validations * remove todo * move proto files to proto/zitadel * change proto path in dockerfile * it compiles! * add validate import * remove duplicate import * fix protos * fix import * tests * cleanup * remove unimplemented methods * iam member multiple queries * all auth and admin calls * add initial password on crate human * message names * management user server * machine done * fix: todos (#1346) * fix: pub sub in new eventstore * fix: todos * fix: todos * fix: todos * fix: todos * fix: todos * fix tests * fix: search method domain * admin service, user import type typescript * admin changes * admin changes * fix: search method domain * more user grpc and begin org, fix configs * fix: return object details * org grpc * remove creation date add details * app * fix: return object details * fix: return object details * mgmt service, project members * app * fix: convert policies * project, members, granted projects, searches * fix: convert usergrants * fix: convert usergrants * auth user detail, user detail, mfa, second factor, auth * fix: convert usergrants * mfa, memberships, password, owned proj detail * fix: convert usergrants * project grant * missing details * changes, userview * idp table, keys * org list and user table filter * unify rest paths (#1381) * unify rest paths * post for all searches, mfa to multi_factor, secondfactor to second_factor * remove v1 * fix tests * rename api client key to app key * machine keys, age policy * user list, machine keys, changes * fix: org states * add default flag to policy * second factor to type * idp id * app type * unify ListQuery, ListDetails, ObjectDetails field names * user grants, apps, memberships * fix type params * metadata to detail, linke idps * api create, membership, app detail, create * idp, app, policy * queries, multi -> auth factors and missing fields * update converters * provider to user, remove old mgmt refs * temp remove authfactor dialog, build finish Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Fabi <[email protected]> Co-authored-by: Livio Amstutz <[email protected]> Co-authored-by: Fabiennne <[email protected]>
232 lines
8.7 KiB
TypeScript
232 lines
8.7 KiB
TypeScript
import { RadioItemAuthType } from 'src/app/modules/app-radio/app-auth-method-radio/app-auth-method-radio.component';
|
|
import {
|
|
APIAuthMethodType,
|
|
APIConfig,
|
|
OIDCAuthMethodType,
|
|
OIDCConfig,
|
|
OIDCGrantType,
|
|
OIDCResponseType,
|
|
} from 'src/app/proto/generated/zitadel/app_pb';
|
|
|
|
export const CODE_METHOD: RadioItemAuthType = {
|
|
key: 'CODE',
|
|
titleI18nKey: 'APP.AUTHMETHODS.CODE.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.CODE.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'CODE',
|
|
background: 'rgb(89 115 128)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
|
|
recommended: false,
|
|
};
|
|
export const PKCE_METHOD: RadioItemAuthType = {
|
|
key: 'PKCE',
|
|
titleI18nKey: 'APP.AUTHMETHODS.PKCE.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.PKCE.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'PKCE',
|
|
background: 'rgb(80 110 92)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
recommended: true,
|
|
};
|
|
export const POST_METHOD: RadioItemAuthType = {
|
|
key: 'POST',
|
|
titleI18nKey: 'APP.AUTHMETHODS.POST.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.POST.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'POST',
|
|
background: 'rgb(144 75 75)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
|
|
notRecommended: true,
|
|
};
|
|
export const PK_JWT_METHOD: RadioItemAuthType = {
|
|
key: 'PK_JWT',
|
|
titleI18nKey: 'APP.AUTHMETHODS.PK_JWT.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.PK_JWT.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'JWT',
|
|
background: 'rgb(89, 93, 128)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
// recommended: true,
|
|
};
|
|
export const BASIC_AUTH_METHOD: RadioItemAuthType = {
|
|
key: 'BASIC',
|
|
titleI18nKey: 'APP.AUTHMETHODS.BASIC.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.BASIC.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'BASIC',
|
|
background: 'rgb(144 75 75)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_CODE,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
|
|
apiAuthMethod: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC,
|
|
};
|
|
|
|
export const IMPLICIT_METHOD: RadioItemAuthType = {
|
|
key: 'IMPLICIT',
|
|
titleI18nKey: 'APP.AUTHMETHODS.IMPLICIT.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.IMPLICIT.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'IMP',
|
|
background: 'rgb(144 75 75)',
|
|
responseType: OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN,
|
|
grantType: OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT,
|
|
authMethod: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
notRecommended: true,
|
|
};
|
|
|
|
export const CUSTOM_METHOD: RadioItemAuthType = {
|
|
key: 'CUSTOM',
|
|
titleI18nKey: 'APP.AUTHMETHODS.CUSTOM.TITLE',
|
|
descI18nKey: 'APP.AUTHMETHODS.CUSTOM.DESCRIPTION',
|
|
disabled: false,
|
|
prefix: 'CUSTOM',
|
|
background: '#333',
|
|
};
|
|
|
|
export function getPartialConfigFromAuthMethod(authMethod: string): {
|
|
oidc?: Partial<OIDCConfig.AsObject>;
|
|
api?: Partial<APIConfig.AsObject>;
|
|
} | undefined {
|
|
let config: {
|
|
oidc?: Partial<OIDCConfig.AsObject>,
|
|
api?: Partial<APIConfig.AsObject>,
|
|
};
|
|
switch (authMethod) {
|
|
case CODE_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
|
|
},
|
|
};
|
|
return config;
|
|
case PKCE_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
}
|
|
};
|
|
return config;
|
|
case POST_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
|
|
}
|
|
};
|
|
return config;
|
|
case PK_JWT_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
},
|
|
api: {
|
|
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
}
|
|
};
|
|
return config;
|
|
case BASIC_AUTH_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
|
|
},
|
|
api: {
|
|
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC,
|
|
}
|
|
};
|
|
return config;
|
|
case IMPLICIT_METHOD.key:
|
|
config = {
|
|
oidc: {
|
|
responseTypesList: [OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN],
|
|
grantTypesList: [OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT],
|
|
authMethodType: OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
},
|
|
api: {
|
|
authMethodType: APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
}
|
|
};
|
|
return config;
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
export function getAuthMethodFromPartialConfig(config: { oidc?: Partial<OIDCConfig.AsObject>, api?: Partial<APIConfig.AsObject>; }): string {
|
|
if (config?.oidc) {
|
|
const toCheck = [config.oidc.responseTypesList, config.oidc.grantTypesList, config.oidc.authMethodType];
|
|
const code = JSON.stringify(
|
|
[
|
|
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_BASIC,
|
|
]
|
|
);
|
|
|
|
const pkce = JSON.stringify(
|
|
[
|
|
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
]
|
|
);
|
|
|
|
const post = JSON.stringify(
|
|
[
|
|
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_POST,
|
|
]
|
|
);
|
|
|
|
const pk_jwt = JSON.stringify(
|
|
[
|
|
[OIDCResponseType.OIDC_RESPONSE_TYPE_CODE],
|
|
[OIDCGrantType.OIDC_GRANT_TYPE_AUTHORIZATION_CODE],
|
|
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
|
|
]
|
|
);
|
|
|
|
const implicit = JSON.stringify(
|
|
[
|
|
[OIDCResponseType.OIDC_RESPONSE_TYPE_ID_TOKEN_TOKEN],
|
|
[OIDCGrantType.OIDC_GRANT_TYPE_IMPLICIT],
|
|
OIDCAuthMethodType.OIDC_AUTH_METHOD_TYPE_NONE,
|
|
]
|
|
);
|
|
|
|
switch (JSON.stringify(toCheck)) {
|
|
case code: return CODE_METHOD.key;
|
|
case pkce: return PKCE_METHOD.key;
|
|
case post: return POST_METHOD.key;
|
|
case pk_jwt: return PK_JWT_METHOD.key;
|
|
case implicit: return IMPLICIT_METHOD.key;
|
|
default:
|
|
return CUSTOM_METHOD.key;
|
|
}
|
|
} else if (config.api && config.api.authMethodType !== undefined) {
|
|
switch (config.api.authMethodType.toString()) {
|
|
case APIAuthMethodType.API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT.toString(): return PK_JWT_METHOD.key;
|
|
case APIAuthMethodType.API_AUTH_METHOD_TYPE_BASIC.toString(): return BASIC_AUTH_METHOD.key;
|
|
default:
|
|
return CUSTOM_METHOD.key;
|
|
}
|
|
} else {
|
|
return CUSTOM_METHOD.key;
|
|
}
|
|
} |