This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2382 from IdentityServer/CustomTokenResponseGener…
…ator Added new service for adding custom entries to a token response
- Loading branch information
Showing
14 changed files
with
157 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
source/Core/Services/Default/DefaultCustomTokenResponseGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using IdentityServer3.Core.Models; | ||
using IdentityServer3.Core.Validation; | ||
using System.Threading.Tasks; | ||
|
||
namespace IdentityServer3.Core.Services.Default | ||
{ | ||
/// <summary> | ||
/// nop custom token response generator | ||
/// </summary> | ||
public class DefaultCustomTokenResponseGenerator : ICustomTokenResponseGenerator | ||
{ | ||
/// <summary> | ||
/// Custom response generation | ||
/// </summary> | ||
/// <param name="request">The validated request.</param> | ||
/// <param name="response">The standard token response.</param> | ||
/// <returns>The custom token response.</returns> | ||
public Task<TokenResponse> GenerateAsync(ValidatedTokenRequest request, TokenResponse response) | ||
{ | ||
return Task.FromResult(response); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2014, 2015 Dominick Baier, Brock Allen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using IdentityServer3.Core.Models; | ||
using IdentityServer3.Core.Validation; | ||
using System.Threading.Tasks; | ||
|
||
namespace IdentityServer3.Core.Services | ||
{ | ||
/// <summary> | ||
/// Allows adding custom data to a token response | ||
/// </summary> | ||
public interface ICustomTokenResponseGenerator | ||
{ | ||
/// <summary> | ||
/// Custom response generation | ||
/// </summary> | ||
/// <param name="request">The validated request.</param> | ||
/// <param name="response">The standard token response.</param> | ||
/// <returns>The custom token response.</returns> | ||
Task<TokenResponse> GenerateAsync(ValidatedTokenRequest request, TokenResponse response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
source/Host.Configuration/Extensions/CustomTokenResponseGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using IdentityServer3.Core.Models; | ||
using IdentityServer3.Core.Services; | ||
using IdentityServer3.Core.Validation; | ||
using System.Threading.Tasks; | ||
|
||
namespace Host.Configuration.Extensions | ||
{ | ||
class CustomTokenResponseGenerator : ICustomTokenResponseGenerator | ||
{ | ||
public Task<TokenResponse> GenerateAsync(ValidatedTokenRequest request, TokenResponse response) | ||
{ | ||
response.Custom.Add("custom_field", "custom data"); | ||
|
||
return Task.FromResult(response); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters