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(authentication): support OpenID Connect #275

Closed
LisaScheers opened this issue Dec 11, 2022 · 17 comments · Fixed by #625
Closed

feat(authentication): support OpenID Connect #275

LisaScheers opened this issue Dec 11, 2022 · 17 comments · Fixed by #625

Comments

@LisaScheers
Copy link

Is your feature request related to a problem? Please describe:

firebase now supports custom OpenID and SAML providers

Describe the solution you'd like:

add a method like signInWithCustomProvider

Describe alternatives you've considered:

NA

Additional context:

Android implementation
IOS implementation
Web Implementation

@djabif
Copy link

djabif commented Mar 26, 2024

Hi @robingenz, thanks for this amazing plugin!
Just wanted to check if you have plans to add this?
My team is considering using an OIDC provider and we also use anonymous login so we need to be able to link the profiles. Thanks 😊

@robingenz
Copy link
Member

It seems like this should be easy to implement. I will add it to my todo list.

@s-frei
Copy link

s-frei commented Apr 30, 2024

Hi, first of all, thank you for your work on this project @robingenz!
We're starting to depend on this feature to provide unique user IDs accross several applications from anohter identity provider.
We are still evaluating if capacitor is the right way for our project, but we won't accomplish to make it work without the custom OIDC provider authentication option.
Did you plan to provide this feature anytime soon? We're also willing to start sponsoring this project!

@robingenz
Copy link
Member

@s-frei There are various ways in which you can prioritize this issue, see After creating an issue. And yes, one of them is sponsoring. Feel free to send me an e-mail to support@capawesome.io if you’re interested.

@seletz
Copy link

seletz commented May 6, 2024

@robingenz just wrote a mail to get this going forward. @s-frei is a collegue of mine.

@robingenz robingenz changed the title feat(authentication): allow custom oAuth providers feat(authentication): support OpenID Connect May 6, 2024
@seletz
Copy link

seletz commented May 6, 2024

@robingenz just wrote a mail to get this going forward. @s-frei is a collegue of mine.

So I've just put in some $$ to sponsor development of this issue. 👍

@robingenz
Copy link
Member

The first dev version is now available:

npm i @capacitor-firebase/authentication@6.0.0-dev.1cf9434.1715181187

There are three new methods:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication';

// See https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseAuth#getPendingAuthResult()
const getPendingAuthResult = async () => {
  const result = await FirebaseAuthentication.getPendingAuthResult();
  return result.user;
};

const signInWithOpenIdConnect = async () => {
  const result = await FirebaseAuthentication.signInWithOpenIdConnect({
    providerId: 'oidc.example.com',
  });
  return result.user;
};

const linkWithOpenIdConnect = async () => {
  const result = await FirebaseAuthentication.linkWithOpenIdConnect({
    providerId: 'oidc.example.com',
  });
  return result.user;
};

I would love to get some feedback.

@s-frei
Copy link

s-frei commented May 8, 2024

Hi @robingenz that was quick, thank you! I will test it and provide feedback on monday 🙂

@s-frei
Copy link

s-frei commented May 13, 2024

As far as I can tell signInWithOpenIdConnect works like a charm 🥳 , at least using Keycloak as OIDC provider. I didn't had to use getPendingAuthResult yet, since there always was an auth result present, or am I missing something?

The linkWithOpenIdConnect I just have to use if I got multiple auth providers and I want to link one authentication to another?

@s-frei
Copy link

s-frei commented May 13, 2024

Well, on iOS the promise returns an error:

{"code":"UNIMPLEMENTED"}

and on Android:

"FirebaseAuthentication.signInWithOpenIdConnect()" is not implemented on android

even tho I see following when launching the apps:

[info] Found 8 Capacitor plugins for ios:
       @capacitor-firebase/authentication@6.0.0-dev.1cf9434.1715181187

[info] Found 8 Capacitor plugins for android:
       @capacitor-firebase/authentication@6.0.0-dev.1cf9434.1715181187

Seems like a caching problem, but I'm not managing to fix it...

EDIT:
The code you added is present in the src-capacitor/node_modules/@capacitor-firebase/authentication/ directory.

@robingenz
Copy link
Member

@s-frei Thank you for your feedback!

I didn't had to use getPendingAuthResult yet, since there always was an auth result present, or am I missing something?

You should call getPendingAuthResult() directly at app start to check if your app was killed by the OS during the auth process.

The linkWithOpenIdConnect I just have to use if I got multiple auth providers and I want to link one authentication to another?

Exactly.

Well, on iOS the promise returns an error:

Sorry, this was my fault. I just published a new version:

npm i @capacitor-firebase/authentication@6.0.0-dev.80d9693.1715591909

Make sure to run npx cap sync after the installation.

and on Android:

It should already work on Android. 🤔

@s-frei
Copy link

s-frei commented May 13, 2024

Now it works on iOS! The issue on Adnroid is unfortunately still the same. I completely rebuilt it an wiped the device data. It seems like the correct code is displayed in Android Studio and I also can find the signInWithOpenIdConnect() method.

@robingenz
Copy link
Member

@s-frei I will take another look at Android later.

@robingenz
Copy link
Member

@s-frei Okay, i fixed one last issue. Now it should also work on Android:

npm i @capacitor-firebase/authentication@6.0.0-dev.19f3631.1715622087

@s-frei
Copy link

s-frei commented May 13, 2024

@robingenz perfect, thank you! Will test it tomorrow.

@s-frei
Copy link

s-frei commented May 14, 2024

@robingenz ok, Android seems to work now! The application gets killed in the background, at least when the browser isn't set up yet. But I guess that is the point where getPendingAuthResult comes handy 🙂

@robingenz
Copy link
Member

@s-frei Exactly! Thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants