Skip to content

Commit

Permalink
feat: added CustomClaimController
Browse files Browse the repository at this point in the history
  • Loading branch information
Grodien committed Jun 13, 2024
1 parent dbb0b63 commit 6360da2
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ch.sbb.playgroundbackend.controller;

import ch.sbb.playgroundbackend.model.azure.Action;
import ch.sbb.playgroundbackend.model.azure.Claims;
import ch.sbb.playgroundbackend.model.azure.TokenIssuanceStartRequest;
import ch.sbb.playgroundbackend.model.azure.TokenIssuanceStartResponse;
import ch.sbb.playgroundbackend.model.azure.TokenIssuanceStartResponseData;
import ch.sbb.playgroundbackend.service.SferaHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("customClaim")
public class CustomClaimController {

private static final Logger log = LoggerFactory.getLogger(CustomClaimController.class);

public CustomClaimController() {

}

@PostMapping
TokenIssuanceStartResponse tokenIssuanceStartEvent(@RequestBody TokenIssuanceStartRequest body) {
log.info("Received request with body: {}", body);


Claims claims = new Claims("1085", "719_2024-06-13", "active");
Action action = new Action("microsoft.graph.tokenIssuanceStart.provideClaimsForToken", claims);
TokenIssuanceStartResponseData responseData = new TokenIssuanceStartResponseData("microsoft.graph.onTokenIssuanceStartResponseData", List.of(action));
TokenIssuanceStartResponse response = new TokenIssuanceStartResponse(responseData);
log.info("Response: {}", response);
return response;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ch.sbb.playgroundbackend.model.azure;

import com.fasterxml.jackson.annotation.JsonProperty;

public record Action(@JsonProperty("@odata.type") String type, Claims claims) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ch.sbb.playgroundbackend.model.azure;

public record AuthenticationClient(String ip, String locale, String market) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ch.sbb.playgroundbackend.model.azure;

public record AuthenticationContext(String correlationId, AuthenticationClient client, String protocol,
ServicePrinciple clientServicePrincipal, ServicePrinciple resourceServicePrincipal,
AzureUser user) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ch.sbb.playgroundbackend.model.azure;

public record AzureUser(String companyName, String createdDateTime, String displayName, String givenName, String id,
String mail, String onPremisesSamAccountName, String onPremisesSecurityIdentifier,
String onPremisesUserPrincipalName, String preferredLanguage, String surname,
String userPrincipalName, String userType) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ch.sbb.playgroundbackend.model.azure;

import com.fasterxml.jackson.annotation.JsonProperty;

public record Claims(@JsonProperty("http://uic.org/90940/ru") String ru,
@JsonProperty("http://uic.org/90940/train") String train,
@JsonProperty("http://uic.org/90940/role") String role) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ch.sbb.playgroundbackend.model.azure;

public record ServicePrinciple(String id, String appId, String appDisplayName, String displayName) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ch.sbb.playgroundbackend.model.azure;

public record TokenIssuanceStartRequest(String type, String source, TokenIssuanceStartRequestData data) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package ch.sbb.playgroundbackend.model.azure;

public record TokenIssuanceStartRequestData(String tenantId, String authenticationEventListenerId,
String customAuthenticationExtensionId,
AuthenticationContext authenticationContext) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ch.sbb.playgroundbackend.model.azure;

public record TokenIssuanceStartResponse(TokenIssuanceStartResponseData data) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ch.sbb.playgroundbackend.model.azure;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public record TokenIssuanceStartResponseData(@JsonProperty("@odata.type") String type, List<Action> actions) {
}

0 comments on commit 6360da2

Please sign in to comment.