Skip to content

Instantly share code, notes, and snippets.

@matjanos
Last active May 27, 2020 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matjanos/2de67edeb9c7e59471d9e13b4d751b63 to your computer and use it in GitHub Desktop.
Save matjanos/2de67edeb9c7e59471d9e13b4d751b63 to your computer and use it in GitHub Desktop.
Refreshing id_tokens in Azure B2C
<TechnicalProfile Id="JwtIssuer">
<DisplayName>JWT Issuer</DisplayName>
<Protocol Name="None" />
<OutputTokenFormat>JWT</OutputTokenFormat>
<Metadata>
<Item Key="client_id">{service:te}</Item>
<Item Key="token_lifetime_secs">##TOKEN_EXPIRY_IN_SEC##</Item>
<Item Key="id_token_lifetime_secs">##TOKEN_EXPIRY_IN_SEC##</Item>
<Item Key="refresh_token_lifetime_secs">##SESSION_EXPIRY_IN_SEC##</Item>
<Item Key="rolling_refresh_token_lifetime_secs">7776000</Item>
<Item Key="issuer_refresh_token_user_identity_claim_type">objectId</Item>
<Item Key="SendTokenResponseBodyWithJsonNumbers">true</Item>
<Item Key="RefreshTokenUserJourneyId">TokenRefresh-RedeemCustomToken</Item>
</Metadata>
<CryptographicKeys>
<Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
<Key Id="issuer_refresh_token_key" StorageReferenceId="B2C_1A_TokenEncryptionKeyContainer" />
</CryptographicKeys>
<InputClaims />
<OutputClaims />
</TechnicalProfile>
[
{
"Kind": "Headers",
"Content": {
"UserJourneyRecorderEndpoint": "urn:journeyrecorder:applicationinsights",
"CorrelationId": "d2659553-30ce-47d7-8070-a014a52a4168",
"EventInstance": "Event:TOKEN",
"TenantId": "xxx.onmicrosoft.com",
"PolicyId": "B2C_1A_SignUpOrSignIn"
}
},
{
"Kind": "Transition",
"Content": {
"EventName": "TOKEN",
"StateName": "Initial"
}
},
{
"Kind": "Predicate",
"Content": "Web.TPEngine.StateMachineHandlers.IsTokenExchangeResourceOwnerFlow"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"Statebag": {
"MACHSTATE": {
"c": "2020-05-27T18:20:54.54717Z",
"k": "MACHSTATE",
"v": "Initial",
"p": true
},
"JC": {
"c": "2020-05-27T18:20:54.54717Z",
"k": "JC",
"v": "en",
"p": true
},
"ComplexItems": "_MachineEventQ, TCTX"
},
"PredicateResult": "False"
}
},
{
"Kind": "Predicate",
"Content": "Web.TPEngine.StateMachineHandlers.ShouldTokenExchangeRunAsUserJourneyHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"PredicateResult": "True"
}
},
{
"Kind": "Predicate",
"Content": "Web.TPEngine.StateMachineHandlers.ShouldTokenExchangeInvokeOrchestrationManagerHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"PredicateResult": "False"
}
},
{
"Kind": "Predicate",
"Content": "Web.TPEngine.StateMachineHandlers.CheckUserExistenceInDirectoryHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"Statebag": {
"UJ": {
"c": "2020-05-27T18:20:54.5627981Z",
"k": "UJ",
"v": "TokenRefresh-RedeemCustomClaim",
"p": false
},
"ORCH_CS": {
"c": "2020-05-27T18:20:56.5003101Z",
"k": "ORCH_CS",
"v": "4",
"p": true
},
"Complex-CLMS": {
"objectId": "75bb68ad-cbfc-45a9-8b19-a29990eea6d2",
"refreshTokenIssuedOnDateTime": "5/27/2020 6:13:16 PM",
"refreshTokensValidFromDateTime": "2020-04-09T13:02:03Z",
"sub": "Not supported currently. Use oid claim.",
"custom_claim": "renewed-claim. Datetime:2020-05-27T18:20:55Z"
},
"PROT": {
"c": "2020-05-27T18:20:54.6097306Z",
"k": "PROT",
"v": "AAD Request to https://graph.windows.net/ae0e4b7d-a17f-4f2a-9390-3107e9241d8b/users/75bb68ad-cbfc-45a9-8b19-a29990eea6d2?api-version=1.6-integrationOnly using method GET as request body is malformed.\r\nResponse: \n{xxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\r\n",
"p": false
},
"ComplexItems": "_MachineEventQ, TCTX, EX_T"
},
"PredicateResult": "True"
}
},
{
"Kind": "Predicate",
"Content": "Web.TPEngine.StateMachineHandlers.NoOpHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"PredicateResult": "True"
}
},
{
"Kind": "Action",
"Content": "Web.TPEngine.StateMachineHandlers.TokenExchangeHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true,
"Statebag": {
"ComplexItems": "_MachineEventQ, TCTX, EX_T, REPRM, AUPRM, PRMCH"
}
}
},
{
"Kind": "Action",
"Content": "Web.TPEngine.StateMachineHandlers.TransactionEndHandler"
},
{
"Kind": "HandlerResult",
"Content": {
"Result": true
}
}
]
<UserJourney Id="TokenRefresh-RedeemCustomToken">
<PreserveOriginalAssertion>false</PreserveOriginalAssertion>
<OrchestrationSteps>
<OrchestrationStep Order="1" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="RefreshTokenSetupExchange" TechnicalProfileReferenceId="SM-RefreshTokenReadAndSetup" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="2" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="CheckRefreshTokenDateFromAadExchange" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId-CheckRefreshTokenDate" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="3" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="GetCustomClaim" TechnicalProfileReferenceId="AzureFunctions-GetCustomClaim" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="4" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
</OrchestrationSteps>
</UserJourney>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment