Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the database cannot be connected, /oauth2/token returns a 401 status code instead of 500 #3671

Open
3 of 5 tasks
Class-public opened this issue Nov 24, 2023 · 1 comment
Labels
bug Something is not working.

Comments

@Class-public
Copy link

Class-public commented Nov 24, 2023

Preflight checklist

Ory Network Project

No response

Describe the bug

When the database cannot be connected, /oauth2/token returns a 401 status code instead of 500

Reproducing the bug

1、Create a OAuht2 Client with Client Credentail Mode
2、Restart the database and immediately request an access token
3、Then you can reproduce the bug

Relevant log output

No response

Relevant configuration

No response

Version

v2.1.2

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes with Helm

Additional Context

No response

@Class-public Class-public added the bug Something is not working. label Nov 24, 2023
@Class-public Class-public changed the title When the database cannot be connected, /oauth2/token returns a 401 status code When the database cannot be connected, /oauth2/token returns a 401 status code instead of 500 Nov 24, 2023
@Class-public
Copy link
Author

Class-public commented Nov 24, 2023

I found that this encapsulates the error information. This is
Any special reason?

func (f *Fosite) DefaultClientAuthenticationStrategy(ctx context.Context, r *http.Request, form url.Values) (Client, error) {
        ...
	client, err := f.Store.GetClient(ctx, clientID)
	if err != nil {
		return nil, errorsx.WithStack(ErrInvalidClient.WithWrap(err).WithDebug(err.Error()))
	}
        ...
}

fosite/errors.go

	ErrInvalidClient = &RFC6749Error{
		ErrorField:       errInvalidClientName,
		DescriptionField: "Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method).",
		CodeField:        http.StatusUnauthorized,
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant