Skip to content

Commit c889428

Browse files
Case sensitive matching
1 parent cef66f9 commit c889428

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

source/DotNetOpenAuth.WebAPI.HostSample/Infrastructure/OAuth/DatabaseKeyNonceStore.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Data.SqlClient;
4-
using System.Linq;
5-
using DotNetOpenAuth.Messaging.Bindings;
6-
7-
namespace DotNetOpenAuth.WebAPI.HostSample.Infrastructure.OAuth {
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data.SqlClient;
4+
using System.Linq;
5+
using DotNetOpenAuth.Messaging.Bindings;
6+
7+
namespace DotNetOpenAuth.WebAPI.HostSample.Infrastructure.OAuth {
88
/// <summary>
99
/// A database-persisted nonce store.
1010
/// </summary>
@@ -57,11 +57,12 @@ public bool StoreNonce(string context, string nonce, DateTime timestampUtc) {
5757
#region ICryptoKeyStore Members
5858

5959
public CryptoKey GetKey(string bucket, string handle) {
60-
// It is critical that this lookup be case-sensitive, which can only be configured at the database.
61-
var matches = from key in MvcApplication.DataContext.SymmetricCryptoKeys
62-
where key.Bucket == bucket && key.Handle == handle
63-
select new CryptoKey(key.Secret, key.ExpiresUtc.AsUtc());
64-
60+
var _db = MvcApplication.DataContext.SymmetricCryptoKeys.Where(k => k.Bucket == bucket && k.Handle == handle).ToList();
61+
// Perform a case senstive match
62+
var matches = from key in _db
63+
where string.Equals(key.Bucket, bucket, StringComparison.Ordinal) &&
64+
string.Equals(key.Handle, handle, StringComparison.Ordinal)
65+
select new CryptoKey(key.Secret, key.ExpiresUtc.AsUtc());
6566
return matches.FirstOrDefault();
6667
}
6768

0 commit comments

Comments
 (0)