Does anyone know how to implement Auth0 hosted login page? - authentication

I am working on a SPA (Angular 1.5.x with Auth0) and saw that I could customize the widget login page. Auth0 provided a generated custom login's URL that includes the Client ID, but no visible instructions on how to integrate it into my project.
If anyone has, can you provide instructions as to how you integrated the Auth0 Hosted Login Page?

You can show this login page by redirecting to the /authorize endpoint and not specifying a connection parameter. If a connection is specified, the user will directly by redirected to log in with that specific identity provider.

Related

Is this SSO scenario possible with FusionAuth?

I go to my application and check if there is JWT cookie
If it is there, I parse it and start to verify if user have access to my application
If it is not there, I will redirect user to authenticate in FusionAuth
After successful login, user will be redirected back to my application
How do I specify in step 3 fusionauth id of my application?
And how do I specify that I want to redirect to my application after successful login?
I assume that fusionauth is running on fusionauth.mydomain.com and application on myapp.mydomain.com and JWT cookie will be issued in mydomain.com, so it will be visible for both.
Yes, this is possible.
In step 3, you will redirect the browser to the FusionAuth login page. Navigate to Settings --> Applications in the FusionAuth UI and click on the green view button for the application in questio.
This will bring up a dialog which will show integration information (if you're on a recent version of FusionAuth).
You'll see a link something like this:
OAuth IdP login URL: https://fusionauth.mydomain.com/oauth2/authorize?client_id=ee31103f-2fc1-4bb5-ba95-ac543693503e&response_type=code&redirect_uri={your URI here}
The client_id parameter in this case will identify your application to FusionAuth.
And how do I specify that I want to redirect to my application after successful login?
This is configured in FusionAuth as an authorized redirect, and then you specify this same URL when redirecting to FusionAuth to login. Notice the redirect_uri parameter in the example URL above. There is a screenshot of this configuration here: https://fusionauth.io/docs/v1/tech/oauth/overview
I assume that fusionauth is running on fusionauth.mydomain.com and application on myapp.mydomain.com and JWT cookie will be issued in mydomain.com, so it will be visible for both.
FusionAuth does not currently drop cross domain cookies. If you are running FusionAuth at fusionauth.mydomain.com the Cookie will have that same domain and not be visible to myapp.mydomain.com.
If you want to leverage FusionAuth, then you do not need to inspect the cookie on myapp.mydomain.com, you'll simply redirect the user if they are not logged in and then if the user already has a SSO session on FusionAuth, they will be seamlessly redirected back to your application.
You can review our login workflows to identify the one that fits your requirements the best and then follow the recommended workflow. https://fusionauth.io/articles/logins/types-of-logins-authentication-workflows
This appears to be a standard OAuth Authorization Code Grant workflow. We have this workflow and many others documented here:
https://fusionauth.io/articles/logins/types-of-logins-authentication-workflows
My guess is that your specific workflow is likely the Authorization Code Grant for Single-Page Applications using JWTs and Refresh Tokens that is documented here:
https://fusionauth.io/articles/logins/spa/oauth-authorization-code-grant-jwts-refresh-tokens-cookies
The way that this works is that you start the OAuth workflow from your application by redirecting the browser to FusionAuth's /oauth2/authorize endpoint. You will need to supply this information to start the OAuth workflow:
client_id - this can be found under the Application configuration in FusionAuth
response_type - for the Authorization Code grant, this will be code
redirect_uri - this is the location you want the user to return to after they log in with FusionAuth. You must configure this URI in FusionAuth under the Application's OAuth configuration tab.
If you are running FusionAuth 1.6.0 or newer, you can also click the "View" icon for your Application and it will display a pop-up dialog that will contain the OAuth URL. You will still need to specify the redirect_uri though. Here is the documentation page for the Authorize endpoint:
https://fusionauth.io/docs/v1/tech/oauth/endpoints#authorize
Once you have that working, you will need to write the Controller for your redirect_uri. This Controller will take the code from the URL that FusionAuth generates and call the /oauth2/token endpoint. This process will exchange the authorization code for an access token, which is a JWT.
The documentation for the /oauth2/otken endpoint is located there:
https://fusionauth.io/docs/v1/tech/oauth/endpoints#token
This will help you implement your Controller.

How to use OAuth 2.0 correctly in SPA?

I'am working on an project where we have a Vue.js Frontend and a Microservices architecture for the backend hosted in Azure Service Fabric.
We wan't to add an IdentityService for authentication using IdentityServer4.
What we want to achieve is a login that is basically the same as stackoverflow provides:
You can login on the website with an embedded login or use external providers like Google and Facebook.
My question only concerns the embedded login.
I have read articles that state using Authorization Code Grant with PKCE is the best way in my scenario. Moreover they say, that Ressource Owner Password Grant should not be used.
But as far as I know, with this flow it is not possible to embed the login to our own website. It will always be a redirect to the IdentityService.
How do Stackoverflow achieve this? Do they use Resource Owner Passwort Grant?
Thank you!
First of all, I welcome you to check how Stackoverflow (SO) handle their user registration process.
SO allows you three options. Login through Google, Facebook or register directly to SO. When someone use Google Or Facebook, SO uses Authorization code flow. User is redirected to respective login page. Once you login there, SO receive user profile details from those identity providers, which allows SO to complete the profile and onboard the user.
But when someone use built in register page, it is simply good old registration page. There is no OAuth involved there. SO obtain end user credentials, complete the profile and save them at their backend.
In your scenario also, you can omit OAuth and use a built in registration or login page. Only concern is the maintenance burden of end user credentials.

IdentityServer4 - Loading login page in iframe

I need to change CSP in response that contains login page from IdentityServer4 in order to render that page in iframe in my client app. Is it possible?
Here you can find a sample MVC application where we have implemented a login mechanism to an IdentityServer4 instance using the authorization code flow but using an iframe. The flow is not that different from redirecting to the authority. Using an iframe just hides the redirection from the user which some believe provides a better user experience.
Regarding IdentityServer4 you need to add the this directive to the CSP. Also it would be good to configure your IS4 not to display a logout prompt, so you can have a seamless logout experience.
The authorize endpoint will already allow this but the login page is under your control so it should be just a matter of setting the CSP header yourself via an MVC filter or similar.
Be aware though that if you use federation to other providers it will likely not work as their CSP will almost certainly not allow your origin as a frame-ancestor.

How to set up the URL/URI for a Client Flow Authentication with Azure AD B2C?

I am working with a mobile app as a Native Client, and trying to set up a simple log in through Azure AD B2C. I been following the documentation but still confused about how to set up correctly all the redirect URLs , as I am getting errors when redirecting the page after a user log in.
I just want to make sure what is the correct way of setting up the following values for a Mobile App Service (e.g. AppName with URL www. https ://AppName.azurewebsites.net) :
Custom redirect URI, in the B2C tenant properties.
Reply URL, in the Sing-Up Sign-In policy.
Allowed external redirect URL, in the Authentication/Authorization of the App service.
Allowed token audiences, in the Azure Active directory Settings.
For a Client Managed Authentication flow you can configure the custom redirect URI to a URL scheme that uniquely identifies the mobile application followed by ://auth/ in B2C Tenant properties and same needs to be configured in the reply URL of the SignUp-SignIn policy. Please refer to Integrating Azure AD B2C with Mobile Apps for more information.
Also, "Allowed External Redirect URL" for your authentication settings in Azure Portal would be {url_scheme_of_your_app}://easyauth.callback where {url_scheme_of_your_app} is the app name in Azure Portal.
Please refer to Add authentication to Xamarin Android App for details.
In the "Allowed Token Audiences" field insert the App ID URL of the application registered earlier.

Forms Authentication and SSO

Created a web based application which needs to integrate forms authentication and SSO. Currently forms authentication will validate all the registered users.
What I need is to integrate SSO as well in to the application. ie, If the user not authenticated then redirect to identity server (Okta) configured with WS-Fed and added the application, validate and response to landing page. Please can you help on this. Please let me know if any more information is required.
Can you please explain this statement " If the user not authenticated then redirect to identity server (Okta) configured with WS-Fed and added the application"?
Please see this link https://github.com/okta/okta-music-store. Under section "Adding Single-sign on to your Music Store" you can see how C# sdk can be used to implement single sign on.
Essentially what you need is a cookieToken from Okta. Using cookieToken as one time token and a redirect url (Can be your app url) you can use /login/sessionCookieRedirect?token=&redirectUrl=. This will create active session with Okta and redirect your user to your app or redirect uri.
Cookie token is obtained via series of two calls. Authentication that gives you session token in response. Session token is exchanged for cookie token via create session call.