Denis Signoretto 5 Years Ago Hi David, first of all thanks for this blog post, very helpful to compare the different approaches Liferay offers as OAuth2 authentication flows. I've a question about the "Resource Owner password credentials". Instead of passing user credentials on the URL (as GET request) Liferay can handle the request as a POST 'application/x-www-form-urlencoded' request? In this case, the credentials are not passed as clear text in the URL. What's your opinion about using this flow in this manner? Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago The Resource Owner auth flow should be a POST, not a GET. I don't know if the values can be passed in the body using x-www-form-encoded but I would bet that it is supported... Please sign in to reply. Reply as... Cancel Denis Signoretto David H Nebinger 5 Years Ago If user/pass can be passed as POST parameters, it's not clear to me why the Cons "Exposes username and password in cleartext". Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago - Edited Because the request, itself, is not secure. It still holds the username and password in cleartext and is therefore a risk. Consider a MITM attack where your request gets routed through a bad guy's infrastructure, you'd still be passing the username and password in cleartext in a form the bad guy can consume. Please sign in to reply. Reply as... Cancel Milen Dyankov Denis Signoretto 5 Years Ago - Edited Yes, they can be passed in the body. So this curl -d 'grant_type=password&username=...&password=...&client_id=...&client_secret=...' https://SERVER/o/oauth2/token is perfectly fine and if used with HTTPS credentials are rather secure. One thing to keep in mind is that some of the OAuth 2 application templates we ask you to choose from, prevents you from having value for "client_secret" field. In such case you should not have "client_secret" field in your request rather than sending an empty one. See: https://issues.liferay.com/browse/LPS-102662 Please sign in to reply. Reply as... Cancel David H Nebinger Milen Dyankov 5 Years Ago At the end of the day, though, the password is neither encrypted nor encoded, so it is still passed in cleartext. So it remains a risk either from the client side (rogue JS library, etc) or a MITM attack or ... Please sign in to reply. Reply as... Cancel Milen Dyankov David H Nebinger 5 Years Ago - Edited It is the exactly same risk you are facing when login in on any HTTPS site ;) If you are saying the risk is that the client (JS app) has to keep the credentials in plain text - that is true but it has nothing to do with the authorization flow. The application may instead securely ask for them on demand or use own means to encrypt them or ... That is whole different discussion. The point I'm making is that the authorization flows itself can be perfectly secured. Please sign in to reply. Reply as... Cancel
David H Nebinger Denis Signoretto 5 Years Ago The Resource Owner auth flow should be a POST, not a GET. I don't know if the values can be passed in the body using x-www-form-encoded but I would bet that it is supported... Please sign in to reply. Reply as... Cancel Denis Signoretto David H Nebinger 5 Years Ago If user/pass can be passed as POST parameters, it's not clear to me why the Cons "Exposes username and password in cleartext". Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago - Edited Because the request, itself, is not secure. It still holds the username and password in cleartext and is therefore a risk. Consider a MITM attack where your request gets routed through a bad guy's infrastructure, you'd still be passing the username and password in cleartext in a form the bad guy can consume. Please sign in to reply. Reply as... Cancel
Denis Signoretto David H Nebinger 5 Years Ago If user/pass can be passed as POST parameters, it's not clear to me why the Cons "Exposes username and password in cleartext". Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago - Edited Because the request, itself, is not secure. It still holds the username and password in cleartext and is therefore a risk. Consider a MITM attack where your request gets routed through a bad guy's infrastructure, you'd still be passing the username and password in cleartext in a form the bad guy can consume. Please sign in to reply. Reply as... Cancel
David H Nebinger Denis Signoretto 5 Years Ago - Edited Because the request, itself, is not secure. It still holds the username and password in cleartext and is therefore a risk. Consider a MITM attack where your request gets routed through a bad guy's infrastructure, you'd still be passing the username and password in cleartext in a form the bad guy can consume. Please sign in to reply. Reply as... Cancel
Milen Dyankov Denis Signoretto 5 Years Ago - Edited Yes, they can be passed in the body. So this curl -d 'grant_type=password&username=...&password=...&client_id=...&client_secret=...' https://SERVER/o/oauth2/token is perfectly fine and if used with HTTPS credentials are rather secure. One thing to keep in mind is that some of the OAuth 2 application templates we ask you to choose from, prevents you from having value for "client_secret" field. In such case you should not have "client_secret" field in your request rather than sending an empty one. See: https://issues.liferay.com/browse/LPS-102662 Please sign in to reply. Reply as... Cancel David H Nebinger Milen Dyankov 5 Years Ago At the end of the day, though, the password is neither encrypted nor encoded, so it is still passed in cleartext. So it remains a risk either from the client side (rogue JS library, etc) or a MITM attack or ... Please sign in to reply. Reply as... Cancel Milen Dyankov David H Nebinger 5 Years Ago - Edited It is the exactly same risk you are facing when login in on any HTTPS site ;) If you are saying the risk is that the client (JS app) has to keep the credentials in plain text - that is true but it has nothing to do with the authorization flow. The application may instead securely ask for them on demand or use own means to encrypt them or ... That is whole different discussion. The point I'm making is that the authorization flows itself can be perfectly secured. Please sign in to reply. Reply as... Cancel
David H Nebinger Milen Dyankov 5 Years Ago At the end of the day, though, the password is neither encrypted nor encoded, so it is still passed in cleartext. So it remains a risk either from the client side (rogue JS library, etc) or a MITM attack or ... Please sign in to reply. Reply as... Cancel Milen Dyankov David H Nebinger 5 Years Ago - Edited It is the exactly same risk you are facing when login in on any HTTPS site ;) If you are saying the risk is that the client (JS app) has to keep the credentials in plain text - that is true but it has nothing to do with the authorization flow. The application may instead securely ask for them on demand or use own means to encrypt them or ... That is whole different discussion. The point I'm making is that the authorization flows itself can be perfectly secured. Please sign in to reply. Reply as... Cancel
Milen Dyankov David H Nebinger 5 Years Ago - Edited It is the exactly same risk you are facing when login in on any HTTPS site ;) If you are saying the risk is that the client (JS app) has to keep the credentials in plain text - that is true but it has nothing to do with the authorization flow. The application may instead securely ask for them on demand or use own means to encrypt them or ... That is whole different discussion. The point I'm making is that the authorization flows itself can be perfectly secured. Please sign in to reply. Reply as... Cancel
Denis Signoretto 5 Years Ago Hi David, I'm trying to configure on Liferay DXP 7.1 an OAuth2 "User Agent Application". If I don't enable the PKCE, every time I call the the authorize URL (https://[hostname]/o/oauth2/authorize?response_type=code&client_id=[client ID]) and authenticate with right user/password Liferay redirected to [your callback URI]?error=unauthorized_client If I enable the PKCE Liferay shows the authorization portlet successfully. It's an expected behaviour or is it a bug? (if the OAuth configuration UI for an User Agent Application let the user disable the PKCE it seems a bug to me). What do you think? (I have tested it on 7.2 and is the same). Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago I don't think you should hit unauthorized user if the creds are right. My first few attempts I didn't have all of the necessary settings (for CORS, etc) and my calls were failing, even though I thought I had everything right. Are you using form encoding and posts and everything correctly? It was only after I was doing everything right that my calls started to go through... Are you coming to Devcon? We could look at it together if you are... Please sign in to reply. Reply as... Cancel
David H Nebinger Denis Signoretto 5 Years Ago I don't think you should hit unauthorized user if the creds are right. My first few attempts I didn't have all of the necessary settings (for CORS, etc) and my calls were failing, even though I thought I had everything right. Are you using form encoding and posts and everything correctly? It was only after I was doing everything right that my calls started to go through... Are you coming to Devcon? We could look at it together if you are... Please sign in to reply. Reply as... Cancel
Denis Signoretto 5 Years Ago Hi David, one more question. I've configured an OAuth2 application as "User Agent Application" but refresh token is not available. Is it a Liferay choice or an OAuth2 recommendation to avoid refresh tokens usage with SPA? By the way, if I'm not wrong refresh token in Liferay never expires. Do you think can be added a feature request for refresh token rotation? (a feature that invalidates a refresh token and issues a new one whenever it is used to refresh an access token. Rif. https://auth0.com/blog/oauth2-implicit-grant-and-spa/) Thanks, Denis Please sign in to reply. Reply as... Cancel David H Nebinger Denis Signoretto 5 Years Ago Not all of the flows support a refresh token; I don't think it is intended as a recommendation for SPAs, I just think it is defined as part of the authorization flow. Refresh tokens do expire, but I think the default expiration time is really long. If you check the response you get back from oauth you'll find a field that holds the refresh token ttl info. The timeout is not fixed, it can be configured btw. Please sign in to reply. Reply as... Cancel Denis Signoretto David H Nebinger 5 Years Ago Hi David, I've seen that Liferay has already implemented the Refresh Token Rotation (https://issues.liferay.com/browse/OAUTH2-227). It's not enabled by default - cool thing!!! The duration of refresh token as you mentioned (is not in the the response in accordingly with RFC) can be configured in OAuth2 System Settings. The default in Liferay 7.2 is 7 days (604800). About "User Agent Application" I suppose it's a Liferay configuration wizard (OAuth2 reccomends now to use authorization code flow with an empty client_secret). I don't understand why refresh tokens are not optional. WDYT? Can you check it with some Liferay Engineer why? (I'm sorry, unfortunately I'll not at DEVCON. Without anabling PCKE I can't get authz step working...). Please sign in to reply. Reply as... Cancel
David H Nebinger Denis Signoretto 5 Years Ago Not all of the flows support a refresh token; I don't think it is intended as a recommendation for SPAs, I just think it is defined as part of the authorization flow. Refresh tokens do expire, but I think the default expiration time is really long. If you check the response you get back from oauth you'll find a field that holds the refresh token ttl info. The timeout is not fixed, it can be configured btw. Please sign in to reply. Reply as... Cancel Denis Signoretto David H Nebinger 5 Years Ago Hi David, I've seen that Liferay has already implemented the Refresh Token Rotation (https://issues.liferay.com/browse/OAUTH2-227). It's not enabled by default - cool thing!!! The duration of refresh token as you mentioned (is not in the the response in accordingly with RFC) can be configured in OAuth2 System Settings. The default in Liferay 7.2 is 7 days (604800). About "User Agent Application" I suppose it's a Liferay configuration wizard (OAuth2 reccomends now to use authorization code flow with an empty client_secret). I don't understand why refresh tokens are not optional. WDYT? Can you check it with some Liferay Engineer why? (I'm sorry, unfortunately I'll not at DEVCON. Without anabling PCKE I can't get authz step working...). Please sign in to reply. Reply as... Cancel
Denis Signoretto David H Nebinger 5 Years Ago Hi David, I've seen that Liferay has already implemented the Refresh Token Rotation (https://issues.liferay.com/browse/OAUTH2-227). It's not enabled by default - cool thing!!! The duration of refresh token as you mentioned (is not in the the response in accordingly with RFC) can be configured in OAuth2 System Settings. The default in Liferay 7.2 is 7 days (604800). About "User Agent Application" I suppose it's a Liferay configuration wizard (OAuth2 reccomends now to use authorization code flow with an empty client_secret). I don't understand why refresh tokens are not optional. WDYT? Can you check it with some Liferay Engineer why? (I'm sorry, unfortunately I'll not at DEVCON. Without anabling PCKE I can't get authz step working...). Please sign in to reply. Reply as... Cancel
Vahid Kh 5 Years Ago Hi David Thanks for your blog But It can't be useful for a interface like React Native that is a mobile application framework. Opening login form inside a popup window in a mobile application or even opening it inside a inApp-Browser inside a mobile app it's not a principled and satisfying solution. There is no solid solution for this kind of authentication? Please sign in to reply. Reply as... Cancel David H Nebinger Vahid Kh 5 Years Ago React native is a slightly different beast, but you can still leverage PKCE. Check out https://formidable.com/blog/2018/oauth-and-pkce-with-react-native/ for at least one example. Please sign in to reply. Reply as... Cancel
David H Nebinger Vahid Kh 5 Years Ago React native is a slightly different beast, but you can still leverage PKCE. Check out https://formidable.com/blog/2018/oauth-and-pkce-with-react-native/ for at least one example. Please sign in to reply. Reply as... Cancel
Muhammad Saleh 3 Years Ago Hi David, I am using client credential mode but I need to extend time limit of my generated token. Thanks in advance Please sign in to reply. Reply as... Cancel
C Fraser 1 Year Ago Hi, I have come here trying to figure out how to use Liferay to do OAuth2 authentication (have something working with Auth0 and want to use Liferay instead... but getting stuck... another storey). Anyway, the reason I am posting is I (in my humble and not too experianced opinion - espically in Liferay) think that some of the statements made above are incorrect... In mutliple places it is mentioned that having the username and password on the URL for an https connetion exposes them to whoever wants to look in cleartext. I believe this is not correct. In https, the URL after the domain name is enctypted in transit. This is what I always believed and can be verfied by multiple sources, e.g. https://stackoverflow.com/questions/499591/are-https-urls-encrypted Just thought it worth noting that ruling out some of the authrotsation flows because of this might not be correct (if that is ineed what you are saying). Also, thanks for your articles... I find them generally helpful :-) Please sign in to reply. Reply as... Cancel C Fraser C Fraser 1 Year Ago Unless you are you just talking about seeing it in the URL on the client? Please sign in to reply. Reply as... Cancel
C Fraser C Fraser 1 Year Ago Unless you are you just talking about seeing it in the URL on the client? Please sign in to reply. Reply as... Cancel