]> source.dussan.org Git - gitea.git/commit
Record OAuth client type at registration (#21316)
authorM Hickford <mirth.hickford@gmail.com>
Mon, 24 Oct 2022 07:59:24 +0000 (09:59 +0200)
committerGitHub <noreply@github.com>
Mon, 24 Oct 2022 07:59:24 +0000 (15:59 +0800)
commit191a74d62254ca00be2ccdf7e3afe69c0f9d6c12
tree68ea1c1f73f2e82c199fc989131f2d23f7ada713
parente1ce45eabf25175d06472fadd01261548a48f1fd
Record OAuth client type at registration (#21316)

The OAuth spec [defines two types of
client](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1),
confidential and public. Previously Gitea assumed all clients to be
confidential.

> OAuth defines two client types, based on their ability to authenticate
securely with the authorization server (i.e., ability to
>   maintain the confidentiality of their client credentials):
>
>   confidential
> Clients capable of maintaining the confidentiality of their
credentials (e.g., client implemented on a secure server with
> restricted access to the client credentials), or capable of secure
client authentication using other means.
>
>   **public
> Clients incapable of maintaining the confidentiality of their
credentials (e.g., clients executing on the device used by the resource
owner, such as an installed native application or a web browser-based
application), and incapable of secure client authentication via any
other means.**
>
> The client type designation is based on the authorization server's
definition of secure authentication and its acceptable exposure levels
of client credentials. The authorization server SHOULD NOT make
assumptions about the client type.

 https://datatracker.ietf.org/doc/html/rfc8252#section-8.4

> Authorization servers MUST record the client type in the client
registration details in order to identify and process requests
accordingly.

Require PKCE for public clients:
https://datatracker.ietf.org/doc/html/rfc8252#section-8.1

> Authorization servers SHOULD reject authorization requests from native
apps that don't use PKCE by returning an error message

Fixes #21299

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 files changed:
docs/content/doc/developers/oauth2-provider.md
models/auth/oauth2.go
models/auth/oauth2_test.go
models/fixtures/oauth2_application.yml
models/fixtures/oauth2_authorization_code.yml
models/fixtures/oauth2_grant.yml
models/migrations/fixtures/Test_addConfidentialClientColumnToOAuth2ApplicationTable/o_auth2_application.yml [new file with mode: 0644]
models/migrations/migrations.go
models/migrations/v230.go [new file with mode: 0644]
models/migrations/v230_test.go [new file with mode: 0644]
modules/convert/convert.go
modules/structs/user_app.go
options/locale/locale_en-US.ini
routers/api/v1/user/app.go
routers/web/auth/oauth.go
routers/web/user/setting/oauth2_common.go
services/forms/user_form.go
templates/swagger/v1_json.tmpl
templates/user/settings/applications_oauth2_edit_form.tmpl
templates/user/settings/applications_oauth2_list.tmpl
tests/integration/api_oauth2_apps_test.go
tests/integration/oauth_test.go