Skip to content

Commit

Permalink
required model properties should have default value
Browse files Browse the repository at this point in the history
  • Loading branch information
jhannes committed Jul 19, 2024
1 parent 3475b59 commit 22d9779
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 58 deletions.
90 changes: 89 additions & 1 deletion snapshotTests/input/openid-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ info:
description: Open ID Connect Discovery
title: Open ID Connect
version: 1.0.0-draft
tags:
- name: Discovery
description: The location of meta-data such as authentication and token urls
- name: IdentityProvider
description: The identity provider
- name: IdentityClient
description: The application to be authenticated. Your application should implement this protocol for the callback uri
paths:
/.well-known/openid-configuration:
get:
Expand All @@ -28,14 +35,22 @@ paths:
$ref: "#/components/schemas/JwksDocument"
/authorize:
get:
operationId: startAuthorization
operationId: authorization
tags: [ IdentityProvider ]
description: Starts an authentication flow. If the request is successful, the user is returned to the redirect_uri with a parameter, otherwise the user is redirected with an error parameter
externalDocs:
url: https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
parameters:
- name: response_type
in: query
required: true
schema:
$ref: "#/components/schemas/ResponseType"
- name: response_mode
in: query
example: query
schema:
type: string
- name: client_id
in: query
required: true
Expand All @@ -47,13 +62,45 @@ paths:
type: string
- name: redirect_uri
in: query
required: true
schema:
type: string
format: uri
- name: scope
in: query
style: spaceDelimited
schema:
type: string
- name: login_hint
in: query
schema:
type: string
- name: prompt
in: query
style: spaceDelimited
schema:
type: array
items:
type: string
enum: [ none, login, consent, select_account ]
- name: acr_values
in: query
style: spaceDelimited
description: "Requested Authentication Context Class Reference values. Space-separated string that specifies the acr values that the Authorization Server is being requested to use for processing this Authentication Request, with the values appearing in order of preference. The Authentication Context Class satisfied by the authentication performed is returned as the acr Claim Value, as specified in Section 2"
schema:
type: array
items:
type: string
- name: nonce
in: query
description: "OPTIONAL. String value used to associate a Client session with an ID Token, and to mitigate replay attacks. The value is passed through unmodified from the Authentication Request to the ID Token"
schema:
type: string
- name: display
in: query
schema:
type: string
enum: [ page, popup, touch, wap ]
responses:
304:
description: User is redirected back to redirect_uri
Expand All @@ -75,6 +122,23 @@ paths:
in: query
schema:
type: string
enum:
- invalid_request
- unauthorized_client
- access_denied
- unsupported_response_type
- invalid_scope
- server_error
- temporarily_unavailable
- invalid_request_uri
- invalid_request_object
- request_not_supported
- request_uri_not_supported
- registration_not_supported
- interaction_required
- login_required
- account_selection_required
- consent_required
- name: error_description
in: query
schema:
Expand Down Expand Up @@ -111,6 +175,7 @@ paths:
content:
application/x-www-form-urlencoded:
schema:
title: TokenForm
type: object
properties:
grant_type:
Expand Down Expand Up @@ -191,16 +256,21 @@ components:
- urn:ietf:params:oauth:grant-type:token-exchange
TokenResponse:
type: object
externalDocs:
url: https://www.rfc-editor.org/rfc/rfc6749#section-5.1
description: Token response according to https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/
properties:
access_token:
type: string
token_type:
type: string
description: The type of token this is. Always the string 'bearer'
externalDocs:
url: https://www.rfc-editor.org/rfc/rfc6749#section-7.1
example: bearer
expires_in:
type: integer
format: int32
description: The duration of time the access token is granted for in seconds
scope:
type: string
Expand Down Expand Up @@ -260,10 +330,14 @@ components:
type: string
description: For JWT from ID-porten, contains national identity number
example: 24079420405
additionalProperties:
items:
type: string
required:
- iss
- aud
- sub
- exp
DiscoveryDocument:
type: object
properties:
Expand Down Expand Up @@ -340,6 +414,9 @@ components:
format: url
required:
- response_types_supported
- authorization_endpoint
- token_endpoint
- issuer
JwksDocument:
type: object
properties:
Expand All @@ -362,6 +439,10 @@ components:
type: string
x5c:
type: string
e:
type: string
n:
type: string
required:
- kid
- x5c
Expand All @@ -381,6 +462,13 @@ components:
properties:
error:
type: string
enum:
- invalid_request
- invalid_client
- invalid_grant
- unauthorized_client
- unsupported_grant_type
- invalid_scope
error_description:
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public final class AddMessageToConversationDeltaDto implements DeltaDto {
private String delta = "AddMessageToConversationDelta";
private UUID conversationId;
private UUID messageId;
private ConversationMessageDto message;
private ConversationMessageDto message = new ConversationMessageDto();

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public final class ConversationSnapshotDto extends ChangeTrackedDto {

private UUID id;
private ConversationInfoDto info;
private ConversationInfoDto info = new ConversationInfoDto();
private Map<String, ConversationMessageSnapshotDto> messages = new HashMap<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public final class CreateConversationDeltaDto implements DeltaDto {

private String delta = "CreateConversationDelta";
private UUID conversationId;
private ConversationInfoDto info;
private ConversationInfoDto info = new ConversationInfoDto();

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public final class UpdateConversationDeltaDto implements DeltaDto {

private String delta = "UpdateConversationDelta";
private UUID conversationId;
private ConversationInfoDto info;
private ConversationInfoDto info = new ConversationInfoDto();

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public final class InfectionDto {

private UUID id;
private InfectionInformationDto information;
private InfectionInformationDto information = new InfectionInformationDto();
private List<ExposureDto> registeredExposures = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,88 @@
import static java.nio.charset.StandardCharsets.UTF_8;

public interface IdentityProviderApi {
/**
* Starts an authentication flow. If the request is successful, the user is returned to the redirect_uri with a parameter, otherwise the user is redirected with an error parameter
* @param response_type (query) (required)
* @param client_id (query) (required)
* @param redirect_uri (query) (required)
* @param response_mode (query) (optional)
* @param state (query) (optional)
* @param scope (query) (optional)
* @param login_hint (query) (optional)
* @param prompt (query) (optional
* @param acr_values Requested Authentication Context Class Reference values. Space-separated string that specifies the acr values that the Authorization Server is being requested to use for processing this Authentication Request, with the values appearing in order of preference. The Authentication Context Class satisfied by the authentication performed is returned as the acr Claim Value, as specified in Section 2 (query) (optional
* @param nonce OPTIONAL. String value used to associate a Client session with an ID Token, and to mitigate replay attacks. The value is passed through unmodified from the Authentication Request to the ID Token (query) (optional)
* @param display (query) (optional)
*
* @see <a href="https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest"> Documentation</a>
*/
void authorization(
ResponseTypeDto response_type,
String client_id,
URI redirect_uri,
Optional<String> response_mode,
Optional<String> state,
Optional<String> scope,
Optional<String> login_hint,
Optional<List<String>> prompt,
Optional<List<String>> acr_values,
Optional<String> nonce,
Optional<String> display
) throws IOException;

@Data
class AuthorizationQuery {
private ResponseTypeDto responseType;
private String responseMode;
private String clientId;
private String state;
private URI redirectUri;
private String scope;
private String loginHint;
private List<String> prompt;
private List<String> acrValues;
private String nonce;
private String display;

public String toUrlEncoded() {
List<String> parameters = new ArrayList<>();
if (responseType != null) {
parameters.add("response_type=" + encode(responseType.toString(), UTF_8));
}
if (responseMode != null) {
parameters.add("response_mode=" + encode(responseMode.toString(), UTF_8));
}
if (clientId != null) {
parameters.add("client_id=" + encode(clientId.toString(), UTF_8));
}
if (state != null) {
parameters.add("state=" + encode(state.toString(), UTF_8));
}
if (redirectUri != null) {
parameters.add("redirect_uri=" + encode(redirectUri.toString(), UTF_8));
}
if (scope != null) {
parameters.add("scope=" + encode(scope.toString(), UTF_8));
}
if (loginHint != null) {
parameters.add("login_hint=" + encode(loginHint.toString(), UTF_8));
}
if (prompt != null) {
parameters.add("prompt=" + encode(prompt.toString(), UTF_8));
}
if (acrValues != null) {
parameters.add("acr_values=" + encode(acrValues.toString(), UTF_8));
}
if (nonce != null) {
parameters.add("nonce=" + encode(nonce.toString(), UTF_8));
}
if (display != null) {
parameters.add("display=" + encode(display.toString(), UTF_8));
}
return String.join("&", parameters);
}
}
/**
* @param grant_type (required)
* @param code (required)
Expand Down Expand Up @@ -91,48 +173,4 @@ UserinfoDto getUserinfo(
class GetUserinfoHeaders {
private String authorization;
}
/**
* Starts an authentication flow. If the request is successful, the user is returned to the redirect_uri with a parameter, otherwise the user is redirected with an error parameter
* @param client_id (query) (required)
* @param response_type (query) (optional)
* @param state (query) (optional)
* @param redirect_uri (query) (optional)
* @param scope (query) (optional)
*/
void startAuthorization(
String client_id,
Optional<ResponseTypeDto> response_type,
Optional<String> state,
Optional<URI> redirect_uri,
Optional<String> scope
) throws IOException;

@Data
class StartAuthorizationQuery {
private ResponseTypeDto responseType;
private String clientId;
private String state;
private URI redirectUri;
private String scope;

public String toUrlEncoded() {
List<String> parameters = new ArrayList<>();
if (responseType != null) {
parameters.add("response_type=" + encode(responseType.toString(), UTF_8));
}
if (clientId != null) {
parameters.add("client_id=" + encode(clientId.toString(), UTF_8));
}
if (state != null) {
parameters.add("state=" + encode(state.toString(), UTF_8));
}
if (redirectUri != null) {
parameters.add("redirect_uri=" + encode(redirectUri.toString(), UTF_8));
}
if (scope != null) {
parameters.add("scope=" + encode(scope.toString(), UTF_8));
}
return String.join("&", parameters);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public String toString() {
}
}

private String issuer = null;
private URI authorization_endpoint = null;
private URI token_endpoint = null;
private String issuer;
private URI authorization_endpoint;
private URI token_endpoint;
private URI userinfo_endpoint = null;
private URI end_session_endpoint = null;
private URI jwks_uri = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ public final class JwksKeyDto {
private String use = null;
private String kid;
private String x5c;
private String e = null;
private String n = null;

}
Loading

0 comments on commit 22d9779

Please sign in to comment.