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

Support for OAuth Logins ? #220

Open
Jan0707 opened this issue Nov 22, 2023 · 13 comments
Open

Support for OAuth Logins ? #220

Jan0707 opened this issue Nov 22, 2023 · 13 comments
Assignees
Labels
question Further information is requested

Comments

@Jan0707
Copy link

Jan0707 commented Nov 22, 2023

Hi 👋

Our directus instance currently only supports login via OAuth (e.g. github).

We would like to use this package, but it seems like you only support login via username/password (e.g. see documentation here: https://nuxt-directus-docs.vercel.app/composables/usedirectusauth#login )

Our current workaround is to manually include a "Login via XYZ" button in the nuxt frontend and have that then again redirect to the nuxt website once, the login/auth flow has completed.

However, when I then try to access the user:

const { fetchUser, setUser } = useDirectusAuth();
let user = useDirectusUser();
if (!user.value) {
  const user = await fetchUser();
  console.log("Fetched User", user);
  setUser(user.value);
}

I only ever get undefined.

Am I missing something or is the whole user composable simply not fit to support this use case?

Any hint would be highly appreciated 🙏

@Jan0707 Jan0707 added the question Further information is requested label Nov 22, 2023
@casualmatt
Copy link
Collaborator

Hi @Jan0707,
Sorry for not getting back to you sooner; SSO is possible with the new v6 module out in beta; we are populating the documentation in the next few weeks.

--> Here is an example from directus documentation:
https://docs.directus.io/self-hosted/sso.html

@Nisthar
Copy link

Nisthar commented Mar 4, 2024

@casualmatt doesn't SSO work on the v5 ?

@casualmatt
Copy link
Collaborator

casualmatt commented Mar 4, 2024

I don't think so.
Probably manually, yes (but you are on your own.).
v6 will support it because v6 is based on the SDK.

@Nisthar
Copy link

Nisthar commented Mar 4, 2024

@casualmatt i am confused which one should i use in my app? i prefer to try v6 but i am not sure if it has everything v5 has

@casualmatt
Copy link
Collaborator

It does, and it adds more stuff.

But we are building the docs, so you must use the IntelliSense and comments on the discussion to navigate it.

@Nisthar
Copy link

Nisthar commented Mar 6, 2024

@casualmatt just found this https://docs.directus.io/releases/breaking-changes.html#session-cookie-based-authentication
it was for their last update. would this affect the auth module of v6?

@casualmatt
Copy link
Collaborator

casualmatt commented Mar 6, 2024

Just last night @sandros94 sent it to me, I think we will take a look at it one of those evening.
But I don't think we will support it for 6.0 more for 6.1/2

But in the new module u will be able to use the SDK to manage the session/cookie. And that way should already work from 6.0.
U can try it, by using the "next" version of the module and disabling Nuxt cookie in the config.

@sandros94
Copy link
Collaborator

@Nisthar @casualmatt

Once we solve #242 I will start working on this. I could even be able to add it as an optional mode even for 6.0.

But considering the nature of this topic, the process will mostly depend on potential upstream issues

@iprokhorov
Copy link

any news on this?

@sandros94
Copy link
Collaborator

any news on this?

The SDK rewrite has been canceled and went back to a nuxt-first approach (RFC #271, current progress #273).

This being said once that PR gets merged this should be available (in the nuxt-directus-next package), but unfortunately I had to slow down its development because of other projects.

Will update as I go along, but could take a bit, since I still need to refactor most of user's authentication yet

@zenojunior
Copy link

The login using the loginWithProvider method works, and when accessing the Directus app, I am logged in. However, const user = useDirectusUser() returns undefined

Directus (CMS): v11.0.2
nuxt-directus: ^5.7.0

Do you have any estimates for solving this problem? Thanks! And congratulations on the great work on this library

@Intevel
Copy link
Owner

Intevel commented Nov 19, 2024

The login using the loginWithProvider method works, and when accessing the Directus app, I am logged in. However, const user = useDirectusUser() returns undefined

Directus (CMS): v11.0.2 nuxt-directus: ^5.7.0

Do you have any estimates for solving this problem? Thanks! And congratulations on the great work on this library

Currently loginWithProvider just does a redirect to a oauth url, and does not set any states.

@yavuz
Copy link
Contributor

yavuz commented Jan 16, 2025

When attempting to log in with loginWithProvider, Google redirects back to the Directus URL for the callback, where the login process occurs. After that, it redirects back to Nuxt. However, since no data is returned to Nuxt, the state on the Nuxt side doesn't change.

If we don't use the Google Auth section in Directus and try to create a user with the data coming from Nuxt, I'm not sure how we would handle the login process. This is because the login method requires sending a username and password.

If anyone has another idea for the OAuth feature, I’ll try to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants