Skip to content

Commit b63a411

Browse files
committed
Merge branch 'master' into gh_2-JWK-Endpoint
2 parents 214e463 + e25e116 commit b63a411

21 files changed

+1305
-23
lines changed

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ build/
33
!gradle/wrapper/gradle-wrapper.jar
44
!**/src/main/**
55
!**/src/test/**
6+
bin/
7+
classes/
8+
target/
9+
*.log
10+
*.log.*
611

712
### STS ###
813
.apt_generated
@@ -32,4 +37,4 @@ out/
3237
.vscode/
3338

3439
### Mac ###
35-
.DS_Store
40+
.DS_Store

CONTRIBUTING.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Contributing to Spring Authorization Server
22

33
Spring Authorization Server is released under the Apache 2.0 license.
4-
If you would like to contribute something, or simply want to hack on the code this document should help you get started.
4+
If you would like to contribute something, or simply want to hack on the code this document should help you https://github.com/spring-projects-experimental/spring-authorization-server#getting-started[get started].
55

66
== Code of Conduct
77
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct].

README.adoc

+19-8
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,33 @@ This project uses https://www.zenhub.com/[ZenHub] to prioritize the feature road
1717
The project board can be accessed https://app.zenhub.com/workspaces/authorization-server-5e8f3182b5e8f5841bfc4902/board?repos=248032165[here].
1818
It is recommended to install the ZenHub https://www.zenhub.com/extension[browser extension] as it integrates natively within GitHub's user interface.
1919

20-
== Code of Conduct
21-
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct].
22-
By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-[email protected].
20+
== Getting Started
21+
The first place to start is to read the https://tools.ietf.org/html/rfc6749[OAuth 2.0 Authorization Framework] to gain an in-depth understanding on how to build an Authorization Server.
22+
It is a critically important first step as the implementation must conform to the specification defined in the OAuth 2.0 Authorization Framework and the https://github.com/spring-projects-experimental/spring-authorization-server/wiki/OAuth-2.0-Specifications[related specifications].
2323

24-
== Downloading Artifacts
25-
See https://github.com/spring-projects/spring-framework/wiki/Downloading-Spring-artifacts[downloading Spring artifacts] for Maven repository information.
24+
The second place to start is to become very familiar with the codebase in the following Spring Security modules:
25+
26+
- https://github.com/spring-projects/spring-security/tree/master/oauth2/oauth2-core[OAuth 2.0 Core]
27+
- https://github.com/spring-projects/spring-security/tree/master/oauth2/oauth2-client[OAuth 2.0 Client]
28+
- https://github.com/spring-projects/spring-security/tree/master/oauth2/oauth2-resource-server[OAuth 2.0 Resource Server]
29+
- https://github.com/spring-projects/spring-security/tree/master/oauth2/oauth2-jose[OAuth 2.0 JOSE] (Javascript Object Signing and Encryption)
30+
31+
A significant amount of effort was put into developing the https://spring.io/blog/2018/01/30/next-generation-oauth-2-0-support-with-spring-security[Next Generation OAuth 2.0 Support in Spring Security].
32+
The goal is to leverage all the knowledge learned thus far and apply the same to the development of Spring Authorization Server.
33+
34+
Submitted work via pull requests should follow the same coding style/conventions and adopt the same or similar design patterns that have been established in Spring Security's OAuth 2.0 support.
2635

2736
== Documentation
2837
Be sure to read the https://docs.spring.io/spring-security/site/docs/current/reference/html5/[Spring Security Reference], as well as the https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2[OAuth 2.0 Reference], which describes the Client and Resource Server features available.
2938

3039
Extensive JavaDoc for the Spring Security code is also available in the https://docs.spring.io/spring-security/site/docs/current/api/[Spring Security API Documentation].
3140

32-
== Quick Start
33-
We recommend that you review the https://tools.ietf.org/html/rfc6749[OAuth 2.0 Authorization Framework] to gain a deep understanding of the framework.
41+
== Code of Conduct
42+
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct].
43+
By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].
3444

35-
The https://oauth.net/2/[OAuth 2.0] website, maintained by Aaron Parecki, provides links to learning resources as well as the various extension specifications.
45+
== Downloading Artifacts
46+
See https://github.com/spring-projects/spring-framework/wiki/Downloading-Spring-artifacts[downloading Spring artifacts] for Maven repository information.
3647

3748
== Building from Source
3849
Spring Authorization Server uses a https://gradle.org[Gradle]-based build system.

core/spring-authorization-server-core.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ dependencies {
1818

1919
provided 'javax.servlet:javax.servlet-api'
2020
}
21+
22+
jacoco {
23+
toolVersion = '0.8.5'
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2020 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+
package org.springframework.security.oauth2.server.authorization;
17+
18+
/**
19+
* Internal class used for serialization across Spring Security Authorization Server classes.
20+
*
21+
* @author Anoop Garlapati
22+
* @since 0.0.1
23+
*/
24+
public final class Version {
25+
private static final int MAJOR = 0;
26+
private static final int MINOR = 0;
27+
private static final int PATCH = 1;
28+
29+
/**
30+
* Global Serialization value for Spring Security Authorization Server classes.
31+
*/
32+
public static final long SERIAL_VERSION_UID = getVersion().hashCode();
33+
34+
public static String getVersion() {
35+
return MAJOR + "." + MINOR + "." + PATCH;
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2020 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+
package org.springframework.security.oauth2.server.authorization.client;
17+
18+
import org.springframework.util.Assert;
19+
20+
import java.util.Arrays;
21+
import java.util.List;
22+
import java.util.Map;
23+
import java.util.concurrent.ConcurrentHashMap;
24+
25+
/**
26+
* A {@link RegisteredClientRepository} that stores {@link RegisteredClient}(s) in-memory.
27+
*
28+
* @author Anoop Garlapati
29+
* @see RegisteredClientRepository
30+
* @see RegisteredClient
31+
* @since 0.0.1
32+
*/
33+
public final class InMemoryRegisteredClientRepository implements RegisteredClientRepository {
34+
private final Map<String, RegisteredClient> idRegistrationMap;
35+
private final Map<String, RegisteredClient> clientIdRegistrationMap;
36+
37+
/**
38+
* Constructs an {@code InMemoryRegisteredClientRepository} using the provided parameters.
39+
*
40+
* @param registrations the client registration(s)
41+
*/
42+
public InMemoryRegisteredClientRepository(RegisteredClient... registrations) {
43+
this(Arrays.asList(registrations));
44+
}
45+
46+
/**
47+
* Constructs an {@code InMemoryRegisteredClientRepository} using the provided parameters.
48+
*
49+
* @param registrations the client registration(s)
50+
*/
51+
public InMemoryRegisteredClientRepository(List<RegisteredClient> registrations) {
52+
Assert.notEmpty(registrations, "registrations cannot be empty");
53+
ConcurrentHashMap<String, RegisteredClient> idRegistrationMapResult = new ConcurrentHashMap<>();
54+
ConcurrentHashMap<String, RegisteredClient> clientIdRegistrationMapResult = new ConcurrentHashMap<>();
55+
for (RegisteredClient registration : registrations) {
56+
Assert.notNull(registration, "registration cannot be null");
57+
String id = registration.getId();
58+
if (idRegistrationMapResult.containsKey(id)) {
59+
throw new IllegalArgumentException("Registered client must be unique. " +
60+
"Found duplicate identifier: " + id);
61+
}
62+
String clientId = registration.getClientId();
63+
if (clientIdRegistrationMapResult.containsKey(clientId)) {
64+
throw new IllegalArgumentException("Registered client must be unique. " +
65+
"Found duplicate client identifier: " + clientId);
66+
}
67+
idRegistrationMapResult.put(id, registration);
68+
clientIdRegistrationMapResult.put(clientId, registration);
69+
}
70+
this.idRegistrationMap = idRegistrationMapResult;
71+
this.clientIdRegistrationMap = clientIdRegistrationMapResult;
72+
}
73+
74+
@Override
75+
public RegisteredClient findById(String id) {
76+
Assert.hasText(id, "id cannot be empty");
77+
return this.idRegistrationMap.get(id);
78+
}
79+
80+
@Override
81+
public RegisteredClient findByClientId(String clientId) {
82+
Assert.hasText(clientId, "clientId cannot be empty");
83+
return this.clientIdRegistrationMap.get(clientId);
84+
}
85+
}

0 commit comments

Comments
 (0)