You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/docs/asciidoc/guides/how-to-jpa.adoc
+24-24
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@
4
4
:docs-dir: ..
5
5
:examples-dir: ../examples
6
6
7
-
[[jpa-getting-started]]
7
+
[[getting-started]]
8
8
== Getting Started
9
9
10
10
This guide shows how to implement the xref:{docs-dir}/core-model-components.adoc#core-model-components[core services] of xref:{docs-dir}/index.adoc#top[Spring Authorization Server] with JPA.
11
11
The purpose of this guide is to provide a starting point for implementing these services yourself, with the intention that you can make modifications to suit your needs.
12
12
13
-
[[jpa-define-data-model]]
13
+
[[define-data-model]]
14
14
== Define the data model
15
15
16
16
This guide provides a starting point for the data model and uses the simplest possible structure and data types.
@@ -20,7 +20,7 @@ NOTE: Except for token, state, metadata, settings, and claims values, we use the
20
20
In reality, the length and even type of columns you use may need to be customized.
21
21
You are encouraged to experiment and test before deploying to production.
22
22
23
-
[[jpa-client-schema]]
23
+
[[client-schema]]
24
24
=== Client Schema
25
25
26
26
The xref:{docs-dir}/core-model-components.adoc#registered-client[`RegisteredClient`] domain object contains a few multi-valued fields and some settings fields that require storing arbitrary key/value data.
@@ -32,7 +32,7 @@ The following listing shows the `client` schema.
The xref:{docs-dir}/core-model-components.adoc#oauth2-authorization[`OAuth2Authorization`] domain object is more complex and contains several multi-valued fields as well as numerous arbitrarily long token values, metadata, settings and claims values.
@@ -49,7 +49,7 @@ The following listing shows the `authorization` schema.
The xref:{docs-dir}/core-model-components.adoc#oauth2-authorization-consent[`OAuth2AuthorizationConsent`] domain object is the simplest to model and contains only a single multi-valued field in addition to a composite key.
@@ -61,15 +61,15 @@ The following listing shows the `authorizationConsent` schema.
The preceding schema examples provide a reference for the structure of the entities we need to create.
68
68
69
69
NOTE: The following entities are minimally annotated and are just examples.
70
70
They allow the schema to be created dynamically and therefore do not require the above sql scripts to be executed manually.
71
71
72
-
[[jpa-client-entity]]
72
+
[[client-entity]]
73
73
=== Client Entity
74
74
75
75
The following listing shows the `Client` entity, which is used to persist information mapped from the xref:{docs-dir}/core-model-components.adoc#registered-client[`RegisteredClient`] domain object.
@@ -80,7 +80,7 @@ The following listing shows the `Client` entity, which is used to persist inform
The following listing shows the `Authorization` entity, which is used to persist information mapped from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization[`OAuth2Authorization`] domain object.
@@ -91,7 +91,7 @@ The following listing shows the `Authorization` entity, which is used to persist
The following listing shows the `AuthorizationConsent` entity, which is used to persist information mapped from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization-consent[`OAuth2AuthorizationConsent`] domain object.
@@ -102,26 +102,26 @@ The following listing shows the `AuthorizationConsent` entity, which is used to
By closely examining the interfaces of each core service and reviewing the `Jdbc` implementations, we can derive a minimal set of queries needed for supporting a JPA version of each interface.
109
109
110
-
[[jpa-client-repository]]
110
+
[[client-repository]]
111
111
=== Client Repository
112
112
113
-
The following listing shows the `ClientRepository`, which is able to find a <<jpa-client-entity,`Client`>> by the `id` and `clientId` fields.
113
+
The following listing shows the `ClientRepository`, which is able to find a <<client-entity,`Client`>> by the `id` and `clientId` fields.
The following listing shows the `AuthorizationRepository`, which is able to find an <<jpa-authorization-entity,`Authorization`>> by the `id` field as well as the `state`, `authorizationCodeValue`, `accessTokenValue` and `refreshTokenValue` token fields.
124
+
The following listing shows the `AuthorizationRepository`, which is able to find an <<authorization-entity,`Authorization`>> by the `id` field as well as the `state`, `authorizationCodeValue`, `accessTokenValue` and `refreshTokenValue` token fields.
125
125
It also allows querying a combination of token fields.
126
126
127
127
.Authorization Repository
@@ -130,52 +130,52 @@ It also allows querying a combination of token fields.
The following listing shows the `AuthorizationConsentRepository`, which is able to find and delete an <<jpa-authorization-consent-entity,`AuthorizationConsent`>> by the `registeredClientId` and `principalName` fields that form a composite primary key.
136
+
The following listing shows the `AuthorizationConsentRepository`, which is able to find and delete an <<authorization-consent-entity,`AuthorizationConsent`>> by the `registeredClientId` and `principalName` fields that form a composite primary key.
With the above <<jpa-create-jpa-entities,entities>> and <<jpa-create-spring-data-repositories,repositories>>, we can begin implementing the core services.
147
+
With the above <<create-jpa-entities,entities>> and <<create-spring-data-repositories,repositories>>, we can begin implementing the core services.
148
148
By reviewing the `Jdbc` implementations, we can derive a minimal set of internal utilities for converting to and from string values for enumerations and reading and writing JSON data for attributes, settings, metadata and claims fields.
149
149
150
150
CAUTION: Keep in mind that writing JSON data to text columns with a fixed length has proven problematic with the `Jdbc` implementations.
151
151
While these examples continue to do so, you may need to split these fields out into a separate table or data store that supports arbitrarily long data values.
152
152
153
-
[[jpa-registered-client-repository]]
153
+
[[registered-client-repository]]
154
154
=== Registered Client Repository
155
155
156
-
The following listing shows the `JpaRegisteredClientRepository`, which uses a <<jpa-client-repository,`ClientRepository`>> for persisting a <<jpa-client-entity,`Client`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#registered-client[`RegisteredClient`] domain object.
156
+
The following listing shows the `JpaRegisteredClientRepository`, which uses a <<client-repository,`ClientRepository`>> for persisting a <<client-entity,`Client`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#registered-client[`RegisteredClient`] domain object.
The following listing shows the `JpaOAuth2AuthorizationService`, which uses an <<jpa-authorization-repository,`AuthorizationRepository`>> for persisting an <<jpa-authorization-entity,`Authorization`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization[`OAuth2Authorization`] domain object.
167
+
The following listing shows the `JpaOAuth2AuthorizationService`, which uses an <<authorization-repository,`AuthorizationRepository`>> for persisting an <<authorization-entity,`Authorization`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization[`OAuth2Authorization`] domain object.
The following listing shows the `JpaOAuth2AuthorizationConsentService`, which uses an <<jpa-authorization-consent-repository,`AuthorizationConsentRepository`>> for persisting an <<jpa-authorization-consent-entity,`AuthorizationConsent`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization-consent[`OAuth2AuthorizationConsent`] domain object.
178
+
The following listing shows the `JpaOAuth2AuthorizationConsentService`, which uses an <<authorization-consent-repository,`AuthorizationConsentRepository`>> for persisting an <<authorization-consent-entity,`AuthorizationConsent`>> and maps to and from the xref:{docs-dir}/core-model-components.adoc#oauth2-authorization-consent[`OAuth2AuthorizationConsent`] domain object.
Spring Authorization Server is a framework that provides implementations of the https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-05[OAuth 2.1] and https://openid.net/specs/openid-connect-core-1_0.html[OpenID Connect 1.0] specifications and other related specifications.
12
12
It is built on top of https://spring.io/projects/spring-security[Spring Security] to provide a secure, light-weight, and customizable foundation for building OpenID Connect 1.0 Identity Providers and OAuth2 Authorization Server products.
13
13
14
-
[[overview-feature-list]]
14
+
[[feature-list]]
15
15
== Feature List
16
16
17
17
Spring Authorization Server supports the following features:
0 commit comments