auth-backend: rename all built-in resolvers

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-04-12 10:43:43 +02:00
parent c93a63586d
commit a479e76604
10 changed files with 42 additions and 35 deletions
+2 -1
View File
@@ -53,7 +53,8 @@ export default async function createPlugin(
...defaultAuthProviderFactories,
google: providers.google.create({
signIn: {
resolver: providers.google.resolvers.lookupEmailAnnotation(),
resolver:
providers.google.resolvers.emailMatchingUserEntityAnnotation(),
},
}),
},
+9 -5
View File
@@ -40,7 +40,7 @@ export default async function createPlugin(
// It is here for demo purposes only.
github: providers.github.create({
signIn: {
resolver: providers.github.resolvers.byUsername(),
resolver: providers.github.resolvers.usernameMatchingUserEntityName(),
},
}),
gitlab: providers.gitlab.create({
@@ -56,22 +56,26 @@ export default async function createPlugin(
}),
microsoft: providers.microsoft.create({
signIn: {
resolver: providers.microsoft.resolvers.lookupEmailAnnotation(),
resolver:
providers.microsoft.resolvers.emailMatchingUserEntityAnnotation(),
},
}),
google: providers.google.create({
signIn: {
resolver: providers.google.resolvers.byEmailLocalPart(),
resolver:
providers.google.resolvers.emailLocalPartMatchingUserEntityName(),
},
}),
okta: providers.okta.create({
signIn: {
resolver: providers.okta.resolvers.lookupEmailAnnotation(),
resolver:
providers.okta.resolvers.emailMatchingUserEntityAnnotation(),
},
}),
bitbucket: providers.bitbucket.create({
signIn: {
resolver: providers.bitbucket.resolvers.lookupUsernameAnnotation(),
resolver:
providers.bitbucket.resolvers.usernameMatchingUserEntityAnnotation(),
},
}),
onelogin: providers.onelogin.create({
+8 -8
View File
@@ -811,8 +811,8 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
lookupUsernameAnnotation(): SignInResolver<OAuthResult>;
lookupUserIdAnnotation(): SignInResolver<OAuthResult>;
usernameMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
userIdMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
}>;
}>;
gcpIap: Readonly<{
@@ -839,7 +839,7 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
byUsername: () => SignInResolver<GithubOAuthResult>;
usernameMatchingUserEntityName: () => SignInResolver<GithubOAuthResult>;
}>;
}>;
gitlab: Readonly<{
@@ -871,8 +871,8 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
byEmailLocalPart: () => SignInResolver<unknown>;
lookupEmailAnnotation(): SignInResolver<OAuthResult>;
emailLocalPartMatchingUserEntityName: () => SignInResolver<unknown>;
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
}>;
}>;
microsoft: Readonly<{
@@ -889,7 +889,7 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
lookupEmailAnnotation(): SignInResolver<OAuthResult>;
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
}>;
}>;
oauth2: Readonly<{
@@ -945,7 +945,7 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
lookupEmailAnnotation(): SignInResolver<OAuthResult>;
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
}>;
}>;
onelogin: Readonly<{
@@ -977,7 +977,7 @@ export const providers: Readonly<{
| undefined,
) => AuthProviderFactory;
resolvers: Readonly<{
byNameId(): SignInResolver<SamlAuthResult>;
nameIdMatchingUserEntityName(): SignInResolver<SamlAuthResult>;
}>;
}>;
}>;
@@ -273,7 +273,7 @@ export const bitbucket = createAuthProviderIntegration({
/**
* Looks up the user by matching their username to the `bitbucket.org/username` annotation.
*/
lookupUsernameAnnotation(): SignInResolver<OAuthResult> {
usernameMatchingUserEntityAnnotation(): SignInResolver<OAuthResult> {
return async (info, ctx) => {
const { result } = info;
@@ -291,7 +291,7 @@ export const bitbucket = createAuthProviderIntegration({
/**
* Looks up the user by matching their user ID to the `bitbucket.org/user-id` annotation.
*/
lookupUserIdAnnotation(): SignInResolver<OAuthResult> {
userIdMatchingUserEntityAnnotation(): SignInResolver<OAuthResult> {
return async (info, ctx) => {
const { result } = info;
@@ -317,14 +317,14 @@ export const createBitbucketProvider = bitbucket.create;
/**
* @public
* @deprecated Use `providers.bitbucket.resolvers.lookupUsernameAnnotation()` instead.
* @deprecated Use `providers.bitbucket.resolvers.usernameMatchingUserEntityAnnotation()` instead.
*/
export const bitbucketUsernameSignInResolver =
bitbucket.resolvers.lookupUsernameAnnotation();
bitbucket.resolvers.usernameMatchingUserEntityAnnotation();
/**
* @public
* @deprecated Use `providers.bitbucket.resolvers.lookupUserIdAnnotation()` instead.
* @deprecated Use `providers.bitbucket.resolvers.userIdMatchingUserEntityAnnotation()` instead.
*/
export const bitbucketUserIdSignInResolver =
bitbucket.resolvers.lookupUserIdAnnotation();
bitbucket.resolvers.userIdMatchingUserEntityAnnotation();
@@ -38,7 +38,7 @@ describe('GithubAuthProvider', () => {
token: `token-for-user:${entityRef.name}`,
})),
} as unknown as AuthResolverContext,
signInResolver: github.resolvers.byUsername(),
signInResolver: github.resolvers.usernameMatchingUserEntityName(),
authHandler: async ({ fullProfile }) => ({
profile: makeProfileInfo(fullProfile),
}),
@@ -367,7 +367,7 @@ export const github = createAuthProviderIntegration({
/**
* Looks up the user by matching their GitHub username to the entity name.
*/
byUsername: (): SignInResolver<GithubOAuthResult> => {
usernameMatchingUserEntityName: (): SignInResolver<GithubOAuthResult> => {
return async (info, ctx) => {
const { fullProfile } = info.result;
@@ -247,11 +247,11 @@ export const google = createAuthProviderIntegration({
/**
* Looks up the user by matching their email local part to the entity name.
*/
byEmailLocalPart: () => commonByEmailLocalPartResolver,
emailLocalPartMatchingUserEntityName: () => commonByEmailLocalPartResolver,
/**
* Looks up the user by matching their email to the `google.com/email` annotation.
*/
lookupEmailAnnotation(): SignInResolver<OAuthResult> {
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult> {
return async (info, ctx) => {
const { profile } = info;
@@ -277,7 +277,7 @@ export const createGoogleProvider = google.create;
/**
* @public
* @deprecated Use `providers.google.resolvers.lookupEmailAnnotation()` instead.
* @deprecated Use `providers.google.resolvers.emailMatchingUserEntityAnnotation()` instead.
*/
export const googleEmailSignInResolver =
google.resolvers.lookupEmailAnnotation();
google.resolvers.emailMatchingUserEntityAnnotation();
@@ -273,7 +273,7 @@ export const microsoft = createAuthProviderIntegration({
/**
* Looks up the user by matching their email to the `microsoft.com/email` annotation.
*/
lookupEmailAnnotation(): SignInResolver<OAuthResult> {
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult> {
return async (info, ctx) => {
const { profile } = info;
@@ -299,7 +299,7 @@ export const createMicrosoftProvider = microsoft.create;
/**
* @public
* @deprecated Use `providers.microsoft.resolvers.lookupEmailAnnotation()` instead.
* @deprecated Use `providers.microsoft.resolvers.emailMatchingUserEntityAnnotation()` instead.
*/
export const microsoftEmailSignInResolver =
microsoft.resolvers.lookupEmailAnnotation();
microsoft.resolvers.emailMatchingUserEntityAnnotation();
@@ -277,7 +277,7 @@ export const okta = createAuthProviderIntegration({
/**
* Looks up the user by matching their email to the `okta.com/email` annotation.
*/
lookupEmailAnnotation(): SignInResolver<OAuthResult> {
emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult> {
return async (info, ctx) => {
const { profile } = info;
@@ -303,6 +303,7 @@ export const createOktaProvider = okta.create;
/**
* @public
* @deprecated Use `providers.okta.resolvers.lookupEmailAnnotation()` instead.
* @deprecated Use `providers.okta.resolvers.emailMatchingUserEntityAnnotation()` instead.
*/
export const oktaEmailSignInResolver = okta.resolvers.lookupEmailAnnotation();
export const oktaEmailSignInResolver =
okta.resolvers.emailMatchingUserEntityAnnotation();
@@ -215,7 +215,7 @@ export const saml = createAuthProviderIntegration({
/**
* Looks up the user by matching their nameID to the entity name.
*/
byNameId(): SignInResolver<SamlAuthResult> {
nameIdMatchingUserEntityName(): SignInResolver<SamlAuthResult> {
return async (info, ctx) => {
const id = info.result.fullProfile.nameID;
@@ -239,6 +239,7 @@ export const createSamlProvider = saml.create;
/**
* @public
* @deprecated Use `providers.saml.resolvers.byNameId()` instead.
* @deprecated Use `providers.saml.resolvers.nameIdMatchingUserEntityName()` instead.
*/
export const samlNameIdEntityNameSignInResolver = saml.resolvers.byNameId();
export const samlNameIdEntityNameSignInResolver =
saml.resolvers.nameIdMatchingUserEntityName();