Conversation
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
improved comments Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
OpenID ConfigurationTo configure OpenID Authentication with Jetty you need to specify the OpenID Provider, Client ID and Client Secret. These can be set as properties in the OpenID ProviderThe OpenID Provider must be an OAuth 2.0 Authentication Server which implements OpenID Connect. To use the jetty-openid module you must input the URL for the OpenID Provider you wish to use. Examples: Registering App with OpenID ProviderYou must register an app with the OpenID provider which will give you a Client ID and Client Secret. Once set up you must also register all the possible URI's for your webapp with the path for example these may look like
WebApp Specific ConfigurationThe webapp should be deployed with a jetty deployable descriptor XML file to configure the security handler with the error page and OpenIdAuthenticatorFactory. The security handler should be given an init param for "org.eclipse.jetty.security.openid.error_page" with a path relative to the webapp where authentication errors should be redirected. ClaimsClaims provide the application with details about the user, such as sub (unique id), name and email. Once a user has been authenticated you can retrieve these claims can be accessed via a Session attribute. ScopesScopes can be used to request additional resources it needs about the user such as additional user claims. For the Google OpenID Provider it can be useful to request the scopes web.xmlTo use OpenID authentication the The realm name must be set to the exact URL string used to set the OpenID Provider. Example: |
|
@WalkerWatch can you help with the documentation for this |
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdCredentials.java
Show resolved
Hide resolved
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdCredentials.java
Outdated
Show resolved
Hide resolved
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdConfiguration.java
Outdated
Show resolved
Hide resolved
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java
Show resolved
Hide resolved
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdLoginService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
| # jetty.openid.openIdProvider=https://accounts.google.com/ | ||
|
|
||
| ## The Client Identifier | ||
| # jetty.openid.clientId=1051168419525-5nl60mkugb77p9j194mrh287p1e0ahfi.apps.googleusercontent.com |
There was a problem hiding this comment.
Is this some fake ID or a real one? You don't want to put here a real ID!
There was a problem hiding this comment.
These were real for my testing app, but I will change to fake ones.
The client secret can be reset easily so didn't think it was a big deal if it was real while testing.
There was a problem hiding this comment.
... and now that a real one has been published, you will need to revoke that from your account, otherwise anybody can start using your account for auth! Low risk I know, but good practise to always cancel any credentials that have been published accidentally.
There was a problem hiding this comment.
Client secrets have been reset.
Except for on Yahoo because the site is so bugged I cannot reset the secret, delete the app, or contact support without errors.
| # jetty.openid.clientId=1051168419525-5nl60mkugb77p9j194mrh287p1e0ahfi.apps.googleusercontent.com | ||
|
|
||
| ## The Client Secret | ||
| # jetty.openid.clientSecret=XT_MIsSv_aUCGollauCaJY8S |
There was a problem hiding this comment.
changed to fake
| public static final String __J_POST = "org.eclipse.jetty.security.openid.POST"; | ||
| public static final String __J_METHOD = "org.eclipse.jetty.security.openid.METHOD"; | ||
| public static final String __CSRF_TOKEN = "org.eclipse.jetty.security.openid.csrf_token"; | ||
| public static final String __J_SECURITY_CHECK = "/j_security_check"; |
There was a problem hiding this comment.
Get rid of the __ in front of public constants.
Why are these public?
There was a problem hiding this comment.
I have removed the __ parts.
This was based off the FormAuthenticator where all the constants are prefixed with __ and are public.
| * If true, uris that cause a redirect to a login page will always | ||
| * be remembered. If false, only the first uri that leads to a login | ||
| * page redirect is remembered. | ||
| * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=379909 |
There was a problem hiding this comment.
What's this URL to a old issue tracking system? Remove it.
| } | ||
| } | ||
|
|
||
|
|
jetty-openid/src/main/java/org/eclipse/jetty/security/openid/OpenIdCredentials.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| InputStream content = (InputStream)connection.getContent(); | ||
| return (Map)JSON.parse(IO.toString(content)); |
There was a problem hiding this comment.
You are leaking the connection open.
There was a problem hiding this comment.
I have changed the InputStream to be used with a try.
Or do I need to explicitly call connection.disconnect()?
| import java.io.Serializable; | ||
| import java.security.Principal; | ||
|
|
||
| public class OpenIdUserPrincipal implements Principal, Serializable |
There was a problem hiding this comment.
No point in making this class Serializable when its only field _credentials is not serializable.
There was a problem hiding this comment.
Removed the Serializable.
There was a problem hiding this comment.
So how is this auth going to work in a cluster? If we have a non sticky load balancer, we need the authentication to move with the session - hence it needs to be serializable.
There was a problem hiding this comment.
I made OpenIdUserPrincipal, OpenIdCredentials and OpenIdConfiguration all Serializable. So now the SessionAuthentication used will allow the authentication to move with the session in a clustered environment.
jetty-util/src/main/java/org/eclipse/jetty/util/security/Constraint.java
Show resolved
Hide resolved
jetty-openid/src/test/java/org/eclipse/jetty/security/openid/OpenIdAuthenticationDemo.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
gregw
left a comment
There was a problem hiding this comment.
I think we need to consider the clustered behaviour of this. @janbartel can you assist.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
|
@sbordet can I get a re-review |
Review and code cleanups. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Allow webapps to authenticate users using the OpenId Connect (OIDC) protocol based on OAuth 2.0. This can be done with any OpenId Provider supporting OIDC. For example by using googles OIDC service you can authenticate with your webapp using your google account.
I have tested authentication with Google, Microsoft and Yahoo so far.
See #137