forked from content-manager-sdk/Community
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleAuthPlugin.cs
More file actions
36 lines (31 loc) · 1 KB
/
GoogleAuthPlugin.cs
File metadata and controls
36 lines (31 loc) · 1 KB
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
using HP.HPTRIM.Service;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Authentication.OAuth2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GoogleAuthPlugin
{
public class Reconfigure : IReconfigure
{
public void Configure(IAppHost appHost)
{
var appSettings = new ServiceStack.Configuration.AppSettings();
if (appHost.Plugins.Exists(p => p is AuthFeature))
{
appHost.Plugins.Remove(appHost.Plugins.First(p => p is AuthFeature));
}
string oauthLogin = appSettings.GetString("oauth.login");
if (oauthLogin == null)
{
oauthLogin = "~/auth/GoogleOAuth";
}
appHost.Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
new GoogleOAuth2Provider(appSettings),
}, oauthLogin));
}
}
}