How to authorise ADFS users from PHP - php

I need to allow adfs user to login in php based application.We can integrate SimpleSAMLphp for this purpose but all we need to make Relay Trust Connection through SAML metadata on ADFS server but we can't do that as client don't allow for this. I didn't found any way to authenticate ADFS user by any single api that we pass user credentials and will get ADFS response is user authorised or not?
Even I don't need any user details from ADFS server only to check weather the user is valid or not?

Need more detail.
This works no problem.
Application --> simpleSAMLphp --> ADFS
What does not work?
SAML does "pass user credentials and will get ADFS response is user authenticated or not".
You need to use roles in the SAML assertions to handle authorisation.

Related

Autheticate via SAML and create token in API

I am working on SAML authentication for my application which has the following architecture.
Frontend application written in Laravel - does not handle authentication
Backed API also written in Laravel which handles authentication
What I have now is a login form that has a login with SAML button which uppon clicked redirects to a Microsoft page and redirects a callback page on the frontend application with information from the saml request.
Now I need to authenticate the user and create a token, then make a session in the frontend application.
Since I was using SAML, I have no password to do a traditional authenticate.
This would mean that I need some API to which I pass some info from SAML to be able to check whether that email exists in the db and subsequently created a token.
But since this API is public, I can't just pass an email because that would allow someone to guess it.
How do I prevent this?
redirects a callback page on the frontend application with information
from the saml request
the information from the SAML request is your authentication event. The user has authenticated to your application by logging in at their Identity Provider (Microsoft page) and returning to your application with their SAML attributes.
If it was a traditional authentication with a username/password, once the password matches, you would create a session for them. In this case the password check was done by Microsoft and told your application it was successful by sending the SAML Response to your callback.
If you parse the SAML Response and extract the attributes you can use one of them to create the session. Something persistent such as eduPersonTargetedID which will always be the same value for that user will let you create their session. When they logout and log back in, that eduPersonTargetedID will have the same value in their SAML Response.
SAML Response samples are available here.

Is possible to make login in Azure behind the scenes

I am working on one project in Angular and PHP, I want to make login on Azure using ADAL (Azure Active Directory Library).
It is possible to do that without popup login Microsoft something like pass only username and password or client secret and to get the token for future request?
The way Azure authenticates external websites is through OAuth 2.0 which requires the user to login to their account on the Azure servers and then give your website authorization code so that you can request an access token to complete the OAuth flow.
It isn't secure to capture the user's Username and Password on your website and then send through to Azure, therefore they do not let you do that.
More explanation of the oAuth flow: https://learn.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code

How to access own API in native application using Google OAuth 2.0 for authentication?

We have an app that uses the OAuth2 Google sign-in system and we want to store data from the users that sign in into our app on our back-end during the initial registration.
This is the way we got it set up:
Users signs in with the app using Google sign-in
We get an ID Token and send this to the server
On the server we verify this token is valid using Google library and save the info we get back from the verification
We also need the user to be able to update/insert data into the back-end when he's authenticated.
After the initial registration, how do we do this?
Do we send the ID Token from client to server each time they call the API on our back-end? In this case how to handle expired tokens?
If you want to make your API a first-class citizen in your system and have it require access tokens that are specifically issued to it instead of accepting Google authentication related tokens that were issued to your client application then you need to have an authorization server that specifically issues tokens for your API.
This authorization server can still delegate user authentication to Google, but then after verifying the user identity it will issue API specific access tokens that better satisfy your requirements, like for example, including specific scopes then used by your API to perform authorization decisions.
For a more complete description of this scenario you can check Auth0 Mobile + API architecture scenario.
In this scenario you have a mobile application ("Client") which talks to an API ("Resource Server"). The application will use OpenID Connect with the Authorization Code Grant using Proof Key for Code Exchange (PKCE) to authenticate users.
The information is Auth0 specific and you can indeed use Auth0 as an authorization server for your own API while still maintaining Google authentication support, however, most of the theory would also apply to any OAuth 2.0 compliant provider.
Disclosure: I'm an Auth0 engineer.

SAML IdP or SP, which do I need

I want to set up a Portal for consumers.
This portal has to have multiple buttons to go to other locations, for example Google and Wordpress.
This by means of SSO, I found out that SAML is best practice for this.
I'm only wondering and trying to find out if my application has to be an IdP (Identity Provider) or an SP (Service Provider).
This application will be made in PHP per request of the client.
Edit
I've looked into simpleSaml, Because the answers I got are good but not concluding. In essention I want this http://documentation.pingidentity.com/display/PF610/IdP-Initiated+SSO--POST with a client portal and I want to go from the client portal to Google analytics, Magento, Wordpress and some local other websites
The IDP authetnicates the users, the SPs then trust the IDP to have authenticated the users correctly.
If your users will authenticate on your site, you will be the IDP. If on the other hand the users log in to google, andyou then trust google for authentication, you will be the SP
IDP stands for Identity Provider who has users information and stores the users databases.
SP stands for Service Provider who allows the users to use its service by getting authenticated from their IDP.
A simple flow is:-
User wants to access the SP website.
SP redirect the user to IDP to log in on IDP.
Once User is successfully logged in there IDP redirect the user to SP with success response.
If SP gets a success response from IDP it allows user access to it.
Now if you got the flow you can easily derive that Google cannot be used as SP has it already contains user database and don't provide the user provisioning (Creation of user at run time).
So with Google, You will be SP and Google will be IDP.
Wordpress provide user provisioning and can be used both as SP and IDP.
So with Wordpress,
If you want your user to login in Wordpress, You will be IDP and Wordpress will be SP. You can try this plugin to achieve it.
If you want Wordpress user to login on your site. You will be SP and Wordpress will be IDP. You can try this plugin to achieve it.
You are the IDP and Google/Wordpress are SPs

is it possible to do authorization using SAML

Currently i am using simplesamlphp and we have successfully implemented SSO, in which SAML request is sending through HTTP-REDIRECT and getting response through HTTP-POST.
Here my doubts are:
Can i send the authentication details(username&password) using HTTP-POST?
Is the simplesamlphp only for authentication or can i use for authorization purpose like oath for Facebook?
When you authenticate with simplesamlPHP, you get a SAML token which contains attributes, These attributes are what are used for authorisation. They can be derived from "a storage of users, a database, a LDAP or a radius interface".
Username can definitely be an attribute. However, password shouldn't be for security reasons.
In terms of authentication, it supports OpenID. For OAuth, I suspect you would have to roll your own authentication module.

Categories