Sample Code for OIDC Implicit Code Flow in Java - oauth-2.0

I am new to implicit flow using OIDC and I am looking for sample code. I could not find anything on internet. Can someone provide links to sample code anywhere.
Any help is really appreciated.

Switching from code flow to implicit flow usually just means changing response_type parameter in your authorization request to token instead of code (or id_token token if you also want the ID token). Then you read the token directly from the response from the Authorization Server (no need to exchange code for token). This should relatively simple to achieve with any OIDC client library, or even just a HTTP client.
Take any OIDC client and change the response_type parameter used by it. If you run any concrete problems I'll be glad to help.

Related

keycloak javascript adapter is safe to use?

The keycloak javascript adapter - based on their documentation uses authorization code flow but with public client.
I just want to know if its offer the same security as authorization code flow with a private client?
Because, as i was discussing it with my colleagues, we realised something.
The implicit flow is not recommended as the access token will be part of the URL - might be stored in the browser history - but is it also not recommended because it will not be encrypted with the TLS/SSL?
In the authorization code flow of keycloak js adapter, keycloak will redirect to js application with authorization code as url parameter, if someone tried to intercept the call, they will be able to get the authorization code and easily exchange to a token as exchanging token won’t require client secret - is it possible to happen? Then for me, this is as good as implicit flow only, right? Or i might have missed something with keycloak’s documentation.
Also, in keycloak, there are 3 types of client - bearer, private and public - is this specific only to keycloak? Or included in oauth2 specifications?

OAuth2AuthorizationCodeGrantFilter vs OAuth2LoginAuthenticationFilter in Spring Security OAuth2 client

When I am trying to understand OAuth2 client, I am confused about why we have two different filters
I attempted to integrate with Github. Here are my observations
OAuth2AuthorizationCodeGrantFilter sound like a filter that exchanges authorization code for access token, but when I keep debug point it does not do that
OAuth2LoginAuthenticationFilter sounds somewhat like it does login somehow, but this filter exchanges auth code to access token instead of above
I'm not sure why this is the case, as the first class name implies some strong correlation to authorization code
Also, Whats is the difference between OAuth2LoginConfigurer & OAuth2ClientConfigurer
Looks like OAuth2LoginConfigurer configures OAuth2LoginAuthenticationFilter, while OAuth2ClientConfigurer configures OAuth2AuthorizationCodeGrantFilter
Can someone explain what each of them does & in which scenarios they are applicable?
Thanks
This is well documented in the Spring Security reference.
OAuth 2.0 Login
OAuth 2.0 Client
As well, in the javadoc:
OAuth2LoginAuthenticationFilter
OAuth2AuthorizationCodeGrantFilter
At a high level:
http.oauth2Login() is an implementation of OpenID Connect Authentication using the Authorization Code Flow
http.oauth2Client().authorizationCodeGrant() is an implementation of OAuth 2.0 Authorization Code grant

OAuth 2 Authorization Code Flow vs Implicit Flow in SPA apps

Almost every oauth 2 doc says that the best option to set up authentication is to use the implicit flow, in case you have a spa app, `cause you can't keep a "client secret" secure on the client side as it runs entirely in a browser, except one article, that I was able to find - https://www.oauth.com/oauth2-servers/single-page-apps/#authorization relating to the option of using code flow to imlicit one.
But what If one uses code flow with no client secret stored on the client side with the neccesary use of the "state" parameter and a pre-registered redirect URL on the server side, as there is no way to verify the identity of the client without the "client secret", as it is described in the link above. Maybe I'm missing something, but just wanna know If such an approach is more secure to use than the implicit flow, that bypasses the code exchange step, or not. Will be glad to hear any suggestions concerning the matter!

spotifpy oauth authorization code flow

The Spotipy library supports the Authorization Code flow as given here http://spotipy.readthedocs.org/en/latest/#module-spotipy.oauth2 but I am still not able to figure out what needs to be passed for 'code' for get_access_token(). The whole oAuth flow is convoluted and hard to follow. Would greatly help if spotipy developers can document one oauth flow with an example.
You can find detailed documentation on the Spotify OAuth flows here.

How do I read claims from my Oauth token?

I made a Security Token Service that connects to my identity store and returns an OAuth2 token with claims if valid. I'm using the Thinktecture.IdentityServer for this. Now I can pass the token to my API, but how do I use this token in my web services to make sure that it returns data that is filtered on the basis of the appropriate claims in the token?
I think some samples might exist here: https://github.com/thinktecture/Thinktecture.IdentityModel.45/tree/master/Samples/Web%20API but I'm not certain I understand what is happening here. Can someone please write a GET that parses identity claims from the jwt token and returns a set of the claims?
I think the answer can be found here, but these integration tests were much more helpful.

Resources