This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
840489c
commit 2f9105c
Showing
23 changed files
with
112 additions
and
359 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
9 changes: 8 additions & 1 deletion
9
src/Stormpath.Owin.Abstractions/Configuration/OktaEnvironmentConfiguration.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
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
49 changes: 49 additions & 0 deletions
49
src/Stormpath.Owin.Middleware/Internal/OrphanAccessTokenBuilder.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,49 @@ | ||
using System; | ||
using System.IdentityModel.Tokens.Jwt; | ||
using System.Security.Claims; | ||
using System.Text; | ||
using Microsoft.IdentityModel.Tokens; | ||
using Stormpath.Owin.Abstractions.Configuration; | ||
|
||
namespace Stormpath.Owin.Middleware.Internal | ||
{ | ||
internal sealed class OrphanAccessTokenBuilder | ||
{ | ||
private readonly IntegrationConfiguration _configuration; | ||
|
||
public OrphanAccessTokenBuilder(IntegrationConfiguration configuration) | ||
{ | ||
_configuration = configuration; | ||
} | ||
|
||
public string Build(string id, string userId, int timeToLive) | ||
{ | ||
var signingKey = _configuration.OktaEnvironment.ClientSecret; | ||
|
||
var signingCredentials = new SigningCredentials( | ||
new SymmetricSecurityKey(Encoding.ASCII.GetBytes(signingKey)), | ||
SecurityAlgorithms.HmacSha256); | ||
|
||
var now = DateTime.UtcNow; | ||
|
||
var claims = new[] | ||
{ | ||
new Claim("sub", id), | ||
new Claim("jti", Guid.NewGuid().ToString()), | ||
new Claim("iat", ((long)((now - Cookies.Epoch).TotalSeconds)).ToString(), ClaimValueTypes.Integer64), | ||
new Claim("cid", _configuration.OktaEnvironment.ClientId), | ||
new Claim("uid", userId) | ||
}; | ||
|
||
var jwt = new JwtSecurityToken( | ||
claims: claims, | ||
issuer: _configuration.Application.Id, | ||
expires: now + TimeSpan.FromSeconds(timeToLive), | ||
notBefore: DateTime.UtcNow, | ||
signingCredentials: signingCredentials, | ||
audience: _configuration.OktaEnvironment.ClientId); | ||
|
||
return new JwtSecurityTokenHandler().WriteToken(jwt); | ||
} | ||
} | ||
} |
70 changes: 0 additions & 70 deletions
70
src/Stormpath.Owin.Middleware/Internal/StormpathTokenExchanger.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Stormpath.Owin.Middleware.Okta | ||
{ | ||
public sealed class AuthorizationServer | ||
{ | ||
public string Id { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string Description { get; set; } | ||
|
||
public List<string> Audiences { get; set; } | ||
|
||
public string Issuer { get; set; } | ||
} | ||
} |
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
Oops, something went wrong.