Git Product home page Git Product logo

laravel-oauth2-login's Introduction

- ๐Ÿ‘‹ Hi, I'm Tobias
- ๐Ÿง web/dev/sysadmin
- ๐Ÿ”ญ js, Vue, React, php, Rust, Dart, .deb GNU Linux

laravel-oauth2-login's People

Contributors

kronthto avatar madagon avatar okaufmann avatar subtronic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

laravel-oauth2-login's Issues

How to fetch logged in user?

Hey @kronthto,

Thanks for making this awesome package!

I wanted to ask how do I get the currently logged in user. I followed the README instructions and do have the OAuth flow working and everything is being stored in the session as expected, but it's not clear to me how to get the currently logged in user.

Auth::user() returns null, how am I supposed to get the user?

Logout

Hi, great package and it saves me a lot of time. ๐Ÿ‘๐Ÿผ

May I know is there any elegant way to logout user?

Check globally if the user is connected

Hello,

The package works well, however, if I want to check if the user is connected on a route that doesn't use the middleware, how would I do it ?
I've seen that to check if the user is connected, you pass the owner resources as an attribute to the request, could it be possible to check for the session all the time instead ?

Add check-only version of the middleware

The current CheckOAuth2 checks the auth, and redirect the User to the OAuth-Authorize-URL if invalid/not logged in.

It is currently not possible to just "check", inject the attributes if logged in, or null/false if not. A usecase would be to display a Login/Logout button, but not force-login the user.

  • Add an alternative middleware that instead of returning a redirect just calls $next without setting "loggedIn"
  • Do this via config / middleware-param switch?
  • It should work with Auth::check

Cleanly use Eloquent alongside OAuthUserWrapper

Hey,

So it'd be really cool if I could have the same kind of object returned from Auth::user() also inherit from Eloquent\Model (to be able to have a hasMany relation for example).

What's clean way to have my wrapper inherit from Eloquent\Model?

I can't do that at the moment because AuthFromRequest currently does

$wrapperClass = config('oauth2login.authWrapper');
return new $wrapperClass($resourceOwner);

and this conflicts with the constructor signature of Model because it takes in an array rather than a ResourceOwnerInterface.

I'd like to be able to simply do Auth::user()->some_has_many_relation for example.

How do you suggest I accomplish this?

The simplest (and very hacky) way I found is to inherit from Model and make a constructor that takes a single parameter, if that parameter is an array (in which case my instance is initialized through Eloquent) simply call the parent constructor with it, if it gets a ResourceOwnerInterface (which I don't use that much because I actually use a JWT access token that has everything I need) instead then it's been initialized from laravel-oauth2-login. This method is quite brittle and I'd prefer to find a cleaner way.

I apologize again if I'm flooding you with questions, still finding my way through Laravel after years of not using it.

Exception when refresh token is expired

I suggest to insert this line

$auth = $this->refreshTokenIfNecessary($auth);

before line
$resourceOwner = $this->oauthService->getTokenUser($auth);

inside try block to catch exceptions during refreshing token.
I have one inconvenient issue: when refresh token is expired, I get IdentityProviderException with message "invalid_grant. refresh token is expired". This is my first time of oauth using, but it seems to me it would be better to redirect user to auth endpoint to begin auth process from the beginning instead of throw exception).
Now to solve this problem I have to create my own middleware extending CheckOAuth2 where handle method has described logic above.

Authenticate from JS

Do we need to pass access token manually in headers when we are accessing protected routes from javascript/AJAX?

Example with axios:

axios.defaults.headers.common = {
    'Authorization': 'Bearer ' + Laravel.apiToken,
};

Is this the correct way to do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.