Recent HN posting - Easy to use OpenID Connect client and server library written for Go https://news.ycombinator.com/item?id=38496264
From Zitadel and its OIDC library:
Highly encourage everyone jump into source code and explore how IntrospectionResponse struct work with all related code around
zitadel/oidc/blob/main/pkg/oidc/introspec...
// IntrospectionResponse implements RFC 7662, section 2.2 and
// OpenID Connect Core 1.0, section 5.1 (UserInfo).
type IntrospectionResponse struct {
Active bool `json:"active"`
Scope SpaceDelimitedArray `json:"scope,omitempty"`
ClientID string `json:"client_id,omitempty"`
TokenType string `json:"token_type,omitempty"`
Expiration Time `json:"exp,omitempty"`
IssuedAt Time `json:"iat,omitempty"`
NotBefore Time `json:"nbf,omitempty"`
Subject string `json:"sub,omitempty"`
Audience Audience `json:"aud,omitempty"`
Issuer string `json:"iss,omitempty"`
JWTID string `json:"jti,omitempty"`
Username string `json:"username,omitempty"`
UserInfoProfile
UserInfoEmail
UserInfoPhone
Address *UserInfoAddress `json:"address,omitempty"`
Claims map[string]any `json:"-"`
}
Start from exploring the difference between identity providers by clicking through
nextauthjs/next-auth/tree/main/packages/c...
export default function Instagram(
config: OAuthUserConfig<Record<string, any>>
): OAuthConfig<Record<string, any>> {
return {
id: "instagram",
name: "Instagram",
type: "oauth",
authorization:
"[https://api.instagram.com/oauth/authorize?scope=user_profile",](https://api.instagram.com/oauth/authorize?scope=user_profile",)
token: "[https://api.instagram.com/oauth/access_token",](https://api.instagram.com/oauth/access_token",)
userinfo:
"[https://graph.instagram.com/me?fields=id,username,account_type,name",](https://graph.instagram.com/me?fields=id,username,account_type,name",)
client: {
token_endpoint_auth_method: "client_secret_post",
},
async profile(profile) {
return {
id: profile.id,
name: profile.username,
email: null,
image: null,
}
},
style: {
logo: "/instagram.svg",
bg: "#fff",
text: "#000",
},
options: config,
}
}
Azure is the most insane ... and it's a lot of fun to compare them all against each other.
Next challenge is to go though PKCE and look how code_challenge, code_verifier works or at least see interfaces.
Ory Fosite is a great alternative too https://github.com/ory/fosite
Support PKCE #59835 in x/oauth2Â https://github.com/golang/go/issues/59835
Scott Brady's content is great for undetstanding the topic
SPA Identity and Access Control with OpenID Connect https://www.youtube.com/watch?v=rP3St0GU_BkÂ
OAuth is Not Authentication https://www.scottbrady91.com/oauth/oauth-is-not-authenticati...
SPA is a landmine ..
OAuth 2.0 and OpenID Connect for Single Page Applications Philippe De Ryck https://www.youtube.com/watch?v=XoBtUn4XczU
The deeper you go into the topic the more you will discover. It's an ultimate "rabbit hole" - web, native, SPA flows, PKCE, JWT, session storage, custome middleware for your favorite flavor of backend framework, etc
Testing against
https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/facebook.ts
In the PKCE (Proof Key for Code Exchange) secure flow of OAuth 2.0, the user's login and password are typically not handled directly by the client application. Instead, these credentials are entered during the authorization process, which usually occurs on a webpage hosted by the authorization server (also known as the identity provider). Here's how it typically works in the PKCE flow:
Client Initiates Authorization Request:
code_challenge
and other necessary OAuth parameters but does not include any user credentials.User Enters Credentials:
Authorization Server Validates Credentials:
Token Exchange with code_verifier
:
code_verifier
to request an access token from the token endpoint of the authorization server.code_verifier
is used to securely prove that the client making the token request is the same one that initiated the authorization request.Access Token Issued:
code_verifier
matches the code_challenge
(which the authorization server received and stored earlier), the server issues an access token (and possibly an ID token in OpenID Connect flows) to the client.code_challenge, code_verifier
code_verifier
. This separation of concerns is a fundamental aspect of OAuth's design, contributing significantly to its security.The OAuth 2.1 Authorization Framework [https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-09#name-redirect-uri-parameter-in-t](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-09#name-redirect-uri-parameter-in-t)
https://openwallet.foundation/governing-board/
https://www.youtube.com/watch?v=PcGaompHYbk
https://www.youtube.com/@Identiverse/videos
OpenID Connect is an interoperable authentication protocol based on the OAuth 2.0 framework of specifications (IETF RFC 6749 and 6750).
Passwordless login with passkeys https://developers.google.com/identity/passkeys
The OAuth 2.1 Authorization Framework [https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-09#name-redirect-uri-parameter-in-t](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-09#name-redirect-uri-parameter-in-t)
D. Hardt
HellĹŤ
A. Parecki
Okta
T. Lodderstedt
yes.com
Introduction to Single Sign-On
Generic Attacks on SSO Procedures
Single-Phase Attacks
Cross-Phase Attacks
Security Best Practices
Secure Token Bindings
Registration:
Very Good: FIDO2 (software) and FIDO2 (physical) factors are based on the FIDO2 specifications [3]. These consist of the two specifications Web Authentication (WebAuthn)[4] and Client-to-Authenticator Protocol (CTAP)[5]. When creating these protocols, security was an important main point, which is also evident in practice.
Good: TOTP (software) and TOTP (physical) both have reasonably good phishing security due to the usually very short validity of the generated codes. However, a major disadvantage is that both the user and the service are in possession of the same shared secret. In case of a compromise of the shared secrets at the service provider, the attacker can use the shared secret himself in a TOTP app to generate valid codes and access the victim’s account.
[1] https://fidoalliance.org/fido2/
[2] https://fidoalliance.org/content/case-study/
[3] https://web.dev/yahoo-japan-identity-case-study/
[4] https://fidoalliance.org/yahoo-japans-password-free-authentication-reduced-inquiries-by-25-sped-up-sign-in-time-by-2-6x/
[5] https://fidoalliance.org/national-health-service-uses-fido-authentication-for-enhanced-login/
[6] https://krebsonsecurity.com/2018/07/google-security-keys-neutralized-employee-phishing/
[7] https://fidoalliance.org/apple-google-and-microsoft-commit-to-expanded-support-for-fido-standard-to-accelerate-availability-of-passwordless-sign-ins/
When implementing OpenID Connect (OIDC) for Single Page Applications (SPAs), there are several security considerations to be aware of, especially related to redirects. Here's what you should know:
Redirect URIs:
Token Handling:
Cross-Site Request Forgery (CSRF) Protection:
XSS (Cross-Site Scripting) Attacks:
Client-Side Security:
Redirect URI Exploitation:
Token Theft via XSS:
CSRF Attacks:
Clickjacking:
Phishing Attacks:
By being aware of these risks and implementing best practices, you can significantly reduce the chances of being hacked in an OIDC implementation for SPAs. It's crucial to stay updated with the latest security practices and to regularly review and update your application's security measures.
OpenID Connect Core: This is the foundational specification, and it hasn't been updated to a "2.0" or "2.1" version. It remains a robust and widely implemented protocol for user authentication.
OAuth 2.1: This proposed update to OAuth 2.0 aims to make things simpler and more secure by incorporating several extensions and best practices that have become widely adopted. Changes include enforcing the use of PKCE (Proof Key for Code Exchange) in all OAuth flows, using only secure authorization codes in OAuth authorization code flow, and removing implicit and password grant types, among others.
As for identity providers implementing OAuth 2.1 or its best practices (which would directly affect how OpenID Connect operates), many leading providers continuously update their services to align with the latest security standards and best practices. Some of these providers include:
These providers often integrate the latest recommendations and practices from the OAuth working group and the OpenID Foundation to ensure security and compliance. However, since OAuth 2.1 is still a draft as of my last update, explicit support for "OAuth 2.1" might not be widely marketed or specifically noted. Instead, providers tend to continuously incorporate individual improvements and recommendations from the OAuth community into their existing OAuth 2.0 and OpenID Connect implementations.
Always check with the specific identity provider for the most current information on their support and implementation of OAuth and OpenID Connect standards.