-
Notifications
You must be signed in to change notification settings - Fork 160
/
SsoServiceInfoFactory.cs
45 lines (36 loc) · 1.34 KB
/
SsoServiceInfoFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using Steeltoe.Extensions.Configuration;
namespace Steeltoe.Connector.Services;
public class SsoServiceInfoFactory : ServiceInfoFactory
{
public SsoServiceInfoFactory()
: base(new Tags("p-identity"), "uaa")
{
}
public override IServiceInfo Create(Service binding)
{
var clientId = GetClientIdFromCredentials(binding.Credentials);
var clientSecret = GetClientSecretFromCredentials(binding.Credentials);
var authDomain = GetStringFromCredentials(binding.Credentials, "auth_domain");
var uri = GetUriFromCredentials(binding.Credentials);
if (!string.IsNullOrEmpty(authDomain))
{
return new SsoServiceInfo(binding.Name, clientId, clientSecret, authDomain);
}
if (!string.IsNullOrEmpty(uri))
{
return new SsoServiceInfo(binding.Name, clientId, clientSecret, UpdateUaaScheme(uri));
}
return null;
}
internal string UpdateUaaScheme(string uaaString)
{
if (uaaString.StartsWith("uaa:"))
{
return "https:" + uaaString.Substring(4);
}
return uaaString;
}
}