Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): Add support for OpenID Connect provider #6574

Merged
merged 13 commits into from
Jan 27, 2023
Merged
4 changes: 4 additions & 0 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,10 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
credential = [FIROAuthProvider credentialWithProviderID:@"oauth"
IDToken:authToken
accessToken:authTokenSecret];
} else if ([provider hasPrefix:@"oidc."] ) {
credential = [FIROAuthProvider credentialWithProviderID:provider
IDToken:authToken
rawNonce:nil];
} else {
DLog(@"Provider not yet handled: %@", provider);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import FacebookAuthProvider from './providers/FacebookAuthProvider';
import GithubAuthProvider from './providers/GithubAuthProvider';
import GoogleAuthProvider from './providers/GoogleAuthProvider';
import OAuthProvider from './providers/OAuthProvider';
import OIDCProvider from './providers/OIDCProvider';
import PhoneAuthProvider from './providers/PhoneAuthProvider';
import TwitterAuthProvider from './providers/TwitterAuthProvider';
import AppleAuthProvider from './providers/AppleAuthProvider';
Expand All @@ -50,6 +51,7 @@ const statics = {
TwitterAuthProvider,
FacebookAuthProvider,
OAuthProvider,
OIDCProvider,
PhoneAuthState: {
CODE_SENT: 'sent',
AUTO_VERIFY_TIMEOUT: 'timeout',
Expand Down
36 changes: 36 additions & 0 deletions packages/auth/lib/providers/OIDCProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const providerId = 'oidc.';

export default class OAuthProvider {
constructor() {
throw new Error('`new OAuthProvider()` is not supported on the native Firebase SDKs.');
}

static get PROVIDER_ID() {
return providerId;
}

static credential(oidcSuffix, idToken, accessToken) {
return {
token: idToken,
secret: accessToken,
providerId: providerId + oidcSuffix,
};
}
}