spa-auth | single page application with authentication support | Runtime Evironment library

 by   naorye JavaScript Version: Current License: No License

kandi X-RAY | spa-auth Summary

kandi X-RAY | spa-auth Summary

spa-auth is a JavaScript library typically used in Server, Runtime Evironment, Angular, Nodejs applications. spa-auth has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

Demonstration of single page application with authentication support using Node.js and AngularJS
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              spa-auth has a low active ecosystem.
              It has 32 star(s) with 12 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 1 have been closed. On average issues are closed in 3 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of spa-auth is current.

            kandi-Quality Quality

              spa-auth has 0 bugs and 0 code smells.

            kandi-Security Security

              spa-auth has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              spa-auth code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              spa-auth does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              spa-auth releases are not available. You will need to build from source code and install.
              Installation instructions are available. Examples and code snippets are not available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spa-auth
            Get all kandi verified functions for this library.

            spa-auth Key Features

            No Key Features are available at this moment for spa-auth.

            spa-auth Examples and Code Snippets

            No Code Snippets are available at this moment for spa-auth.

            Community Discussions

            QUESTION

            Laravel 8 Sanctum SPA Auth - Session store not set on request
            Asked 2021-Feb-09 at 12:56

            I'm trying to implement Sanctum SPA Authentication. I'm getting the following error when trying to login (only in production):

            production.ERROR: Session store not set on request. {"userId":1,"exception":"[object] (RuntimeException(code: 0): Session store not set on request. at /app/vendor/laravel/framework/src/Illuminate/Http/Request.php:483)

            Followed all the steps in the documentation. First calling sanctum/csrf-cookie GET request, then my API login POST request with the session cookie attached. Thank you for any tips!

            My login method in AuthController.php, where the exceptioin is happening on line 28.

            My Http\Kernel.php file with the middleweres for the API endpoints.

            My API endpoint in routes/api.php

            ...

            ANSWER

            Answered 2021-Feb-09 at 12:56

            The authentication routes must be in the routes/web.php file.

            Source https://stackoverflow.com/questions/66048023

            QUESTION

            Laravel API verification/protection on subsequent requests: no login / logout and no "users" table
            Asked 2020-Dec-12 at 00:00

            TLDR; see image below 3 - is that possible and how?

            I read about API protection - Sanctum & Passport, but none of these seems what I can accomplish with my app since it's a little specific and simplified in a way.

            For example, Sanctum's way of authenticating sounds like something I'd like, but without the /login part (i have a custom /auth part, see below.): https://laravel.com/docs/8.x/sanctum#spa-authenticating.

            If the login request is successful, you will be authenticated and subsequent requests to your API routes will automatically be authenticated via the session cookie that the Laravel backend issued to your client.

            My app has no login per se - we log-in the user if they have a specified cookie token verified by the 3rd party API (i know token-auth is not the best way to go, but it is quite a specific application/use). It's on /auth, so Sanctum's description above could work, I guess if I knew where to fiddle with it. Our logic:

            1. VueJS: a mobile device sends an encrypted cookie token - app reads it in JS, sends it to my Laravel API for verification.
            2. Get the token in Laravel API, decrypt, send to 2nd API (not in my control), verifying the token, and sends back an OK or NOT OK response with some data.
            3. If the response was OK, the user is "logged-in."
            4. The user can navigate the app, and additional API responses occur - how do I verify it's him and not an imposter or some1 accessing the API directly in the browser?

            I guess the session could work for that, but it's my 1st time using Laravel, and nothing seemed to work as expected. Also, sessions stored in files or DB are not something I'm looking forward to if required.

            For example, I tried setting a simple session parameter when step 3 above happened and sending it back, but the session store was not set up, yet it seemed at that point. Then I could check that session value to make sure he's the same user that was just verified.

            For an easier understanding of what I'm trying to accomplish and if it's even feasible:

            The main question is, what is the easiest way to have basic API protection/authentication/verification whilst sending the token for authentication to 3rd party API only on 1st request (and if the app is reopened/refreshed of course) - keeping in mind, that no actual users exist on my Laravel API.

            Or would it be best to do the token-auth to the 3rd party API on each request?

            ...

            ANSWER

            Answered 2020-Dec-10 at 15:40

            If I understand your case correctly there's no real User model involved, right? If so, you'll not be able to use any of Laravel's built-in authentication methods as they all rely on the existence of such a model.

            In that case you'll need one endpoint and a custom authentication Middleware that you'll need to create yourself in Laravel in order to handle everything:

            The endpoint definition:

            Source https://stackoverflow.com/questions/65181651

            QUESTION

            Laravel Sanctum : blocked by CORS policy with Nuxt Auth module
            Asked 2020-Sep-25 at 14:34

            I have a Laravel website served by Valet on backend.test and a Nuxt SPA on nuxt.backend.test:3005. When I try to authenticate to Sanctum with Nuxt Auth module, I get the CORS error below:

            Access to XMLHttpRequest at 'http://backend.test/login' from origin 'http://nuxt.backend.test:3005' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

            How can I fix it ?

            Laravel configuration

            config/cors.php:

            ...

            ANSWER

            Answered 2020-Sep-25 at 14:34

            Laravel backend and Nuxt frontend have to be under the same domain, so I finally fixed it in 3 steps:

            1. Add this to /etc/hosts:

            Source https://stackoverflow.com/questions/62115781

            QUESTION

            Laravel Sanctum Prefix returns 404
            Asked 2020-Sep-22 at 07:54

            Trying out Laravel 8 (SPA with Sanctum and VueJS) and strangely I cannot get my Vue SPA to make a successful csrf-cookie request as shown in the documentation(Laravel - SPA Authentication). I have setup my Vue SPA to use base url as /api and I have added 'prefix' => 'api' in my config/sanctum.php. But the request returns a 404 response. If I remove my base url /api from my Vue config and send the csrf-cookie request, I am getting a success (200) response. Am I missing something ?

            ...

            ANSWER

            Answered 2020-Sep-22 at 07:54

            well the prefix overwrite the sanctum prefix so if you wanna set route api/sanctum/csrf-cookie set your prefix api/sanctum. a good way too see that is look at route list by php artisan route:list.

            ref: https://github.com/laravel/sanctum/blob/2.x/src/SanctumServiceProvider.php#L81

            Source https://stackoverflow.com/questions/64005159

            QUESTION

            CSRF Cookies Not Set for Cross Domain Requests using Laravel Sanctum and Angular
            Asked 2020-May-08 at 02:33
            Overview

            I have a Laravel powered api locally hosted at http://tenant.api.hydrogen.local and an Angular 9.2 SPA which is being served on http://localhost:8100. I recently installed Laravel Sanctum for authentication and followed instructions for SPA's listed in the docs but the CSRF token is not attached to requests from the SPA and I therefore receive a CSRF token mismatch error.

            As instructed I make an initial call to //abc.api.hydrogen.local/sanctum/csrf before subsequently attempting to login in:

            ...

            ANSWER

            Answered 2020-May-08 at 02:33

            This problem occurred because the browser/angular will only attach cookies to requests that have the same domain as where the request is coming from.

            To fix this in the dev environment where the angular app is being served on localhost and the Laravel app is on a domain like abc.api.hydrogen.local I proxied requests from the angular app:

            First ensure your requests are relative routes, for example I changed my calls to /api/sanctum/crsf which then gets proxied to http://abc.api.hydrogen.local/sanctum/crsf

            Then create a proxy configuration proxy.conf.json in the root of the project:

            Source https://stackoverflow.com/questions/61535144

            QUESTION

            Identity Server 4 is not redirecting to Angular app after login
            Asked 2020-Mar-03 at 22:01

            I am using oidc-client in angular. following this Tutorial

            ...

            ANSWER

            Answered 2019-Mar-10 at 13:55

            I see there's a bit of confusion concerning the difference between the returnUrl and the redirect_uri. Although the end goal is a redirect to the client's redirect_uri, after authentication the client must actually redirect to the authorize endpoint for further processing (hence the reason why the url is different). You shouldn't need to change the returnUrl at all and can leave it the way it was.

            The problem you're facing now is you're not calling HttpContext.SignInAsync after a successful authentication. The SignInAsync method is used to administer a cookie with the user's information that tells the endpoint at the returnUrl that the user was successfully authenticated, and it's okay to return a token to the redirect_uri. There are a lot of overloads for the SignInAsync, but the one I find easiest to use is HttpContext.SignInAsync(string subject, params Claim[] claims). After doing this you should be able to finish the authentication.

            Source https://stackoverflow.com/questions/55046210

            QUESTION

            IdentityServer External auth provider - auth-callback - Redirection - 400 Bad request
            Asked 2019-Aug-27 at 05:54

            I am following https://www.scottbrady91.com/Angular/SPA-Authentiction-using-OpenID-Connect-Angular-CLI-and-oidc-client and https://www.scottbrady91.com/Angular/Migrating-oidc-client-js-to-use-the-OpenID-Connect-Authorization-Code-Flow-and-PKCE to implement OIDC in SPA(Angular)

            I am using aspboilerplate integrated IdentityServer

            I've set up everything as per the above articles and I was able to navigate to external auth provider and was also able to enter the required credentials.

            While redirecting to angular I am getting 400 - Bad request. Here are the details

            Call back URL :

            ...

            ANSWER

            Answered 2019-Aug-22 at 07:20

            Just try with few fixes. First - RedirectUris seems suspicious, since it contains more than one value, - according to the http://docs.identityserver.io/en/latest/topics/clients.html - declaring this as a List could be the source of the issues.

            Next, following the example of server side config https://github.com/IdentityServer/IdentityServer4.Demo/blob/master/src/IdentityServer4Demo/Config.cs

            Source https://stackoverflow.com/questions/57552543

            QUESTION

            Laravel 5.6 - How to authenticate API using sessions for same folder SPA?
            Asked 2019-Jan-18 at 21:11

            I have a React SPA in the same Laravel project. The login/signup/logout and all other js views are in the js folder and use axios api calls for all POST/GET requests. I want to use the default Laravel session based web authentication for the embedded SPA, since it's in the same project folder and it will be the only javascript client accessing it. This api does not need to be open to the public, just for this react app, and it's an SPA for the speed and good user experience instead of full page reloads.

            I've tried using Passport before, and for over a month, I still can't get it to work as intended. I do not want to deal with tokens, access tokens, refresh tokens, revoking tokens, CSRF, etc. Just the out of the box simple Laravel session based auth that works so easily on web, but want it to work on my react app. The only blade file is the index.blade.php which includes the react app.js

            Any idea how we can accomplish this?

            UPDATE 1:

            After implementing @ceejayoz's suggestion:

            You have to add the various Session/Cookie middlewares in app/Http/Kernel.php (stuff like \Illuminate\Session\Middleware\StartSession::class) to the API routes.

            I added to $middlewareGroups.api to match the web middleware in app/Http/Kernel.php:

            ...

            ANSWER

            Answered 2019-Jan-16 at 04:06

            It's doable (and I've done the same myself for some apps).

            By default, the routes in routes/api.php don't have sessions available, but you can add the various Session/Cookie middlewares in app/Http/Kernel.php (stuff like \Illuminate\Session\Middleware\StartSession::class) to the API routes.

            You can, as @ljubadr suggested, also put the API routes right in routes/web.php instead, although that'd probably mean you'd need to make other changes (like removing CSRF protection from the web routes).

            Source https://stackoverflow.com/questions/54207938

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install spa-auth

            This is demonstration of single page application with authentication support. This repository contains the application with and without authentication. More information can be found here: http://www.webdeveasy.com/single-page-application-authentication.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/naorye/spa-auth.git

          • CLI

            gh repo clone naorye/spa-auth

          • sshUrl

            git@github.com:naorye/spa-auth.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link