File tree Expand file tree Collapse file tree 6 files changed +137
-1
lines changed
features/integrations/rest
java/org/springframework/security/docs/features/integrations/rest/type
kotlin/org/springframework/security/kt/docs/features/integrations/rest/type Expand file tree Collapse file tree 6 files changed +137
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ include-code::./UserService[tag=getAuthenticatedUser]
51
51
52
52
The xref:features/integrations/rest/http-interface.adoc#client-registration-id[`@ClientRegistrationId`] will be processed by xref:features/integrations/rest/http-interface.adoc#client-registration-id-processor[`ClientRegistrationIdProcessor`]
53
53
54
+ [[type]]
55
+ === Type Level Declarations
56
+
57
+ `@ClientRegistrationId` can also be added at the type level to avoid repeating the declaration on every method.
58
+
59
+ include-code::./UserService[tag=type]
60
+
54
61
[[client-registration-id-processor]]
55
62
== `ClientRegistrationIdProcessor`
56
63
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ http.csrf((csrf) -> csrf.spa());
49
49
* Added OAuth2 Support for xref:features/integrations/rest/http-interface.adoc[HTTP Interface Integration]
50
50
* Added support for custom `JwkSource` in `NimbusJwtDecoder`, allowing usage of Nimbus's `JwkSourceBuilder` API
51
51
* Added builder for `NimbusJwtEncoder`, supports specifying an EC or RSA key pair or a secret key
52
- * Added support for `@ClientRegistrationId` at class level, eliminating the need for method level repetition
52
+ * Added support for `@ClientRegistrationId` at the xref:features/integrations/rest/http-interface.adoc#type[type level] , eliminating the need for method level repetition
53
53
54
54
== SAML 2.0
55
55
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2004-present the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org .springframework .security .docs .features .integrations .rest .type ;
18
+
19
+ /**
20
+ * Used to ensure {@link UserService} compiles, but not show in the documentation.
21
+ *
22
+ * @author Rob Winch
23
+ */
24
+ public record Hovercard () {
25
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2004-present the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain clients copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org .springframework .security .docs .features .integrations .rest .type ;
18
+
19
+ import org .springframework .security .docs .features .integrations .rest .clientregistrationid .User ;
20
+ import org .springframework .security .oauth2 .client .annotation .ClientRegistrationId ;
21
+ import org .springframework .web .bind .annotation .PathVariable ;
22
+ import org .springframework .web .service .annotation .GetExchange ;
23
+ import org .springframework .web .service .annotation .HttpExchange ;
24
+
25
+ /**
26
+ * Demonstrates a service for {@link ClientRegistrationId} at the type level.
27
+ * @author Rob Winch
28
+ */
29
+ // tag::type[]
30
+ @ HttpExchange
31
+ @ ClientRegistrationId ("github" )
32
+ public interface UserService {
33
+
34
+ @ GetExchange ("/user" )
35
+ User getAuthenticatedUser ();
36
+
37
+ @ GetExchange ("/users/{username}/hovercard" )
38
+ Hovercard getHovercard (@ PathVariable String username );
39
+
40
+ }
41
+ // end::type[]
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2004-present the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.security.kt.docs.features.integrations.rest.type
18
+
19
+ /* *
20
+ * Used to ensure [UserService] compiles, but not show in the documentation.
21
+ *
22
+ * @author Rob Winch
23
+ */
24
+ class Hovercard
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2004-present the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain clients copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package org.springframework.security.kt.docs.features.integrations.rest.type
18
+
19
+ import org.springframework.security.kt.docs.features.integrations.rest.clientregistrationid.User
20
+ import org.springframework.security.oauth2.client.annotation.ClientRegistrationId
21
+ import org.springframework.web.bind.annotation.PathVariable
22
+ import org.springframework.web.service.annotation.GetExchange
23
+ import org.springframework.web.service.annotation.HttpExchange
24
+
25
+ /* *
26
+ * Demonstrates a service for [ClientRegistrationId] at the type level.
27
+ * @author Rob Winch
28
+ */
29
+ // tag::type[]
30
+ @HttpExchange
31
+ @ClientRegistrationId(" github" )
32
+ interface UserService {
33
+ @GetExchange(" /user" )
34
+ fun getAuthenticatedUser (): User
35
+
36
+ @GetExchange(" /users/{username}/hovercard" )
37
+ fun getHovercard (@PathVariable username : String ): Hovercard
38
+ }
39
+ // end::type[]
You can’t perform that action at this time.
0 commit comments