コード例 #1
0
 public AccountLinkingController(
     ILogger <AccountLinkingController> logger,
     OAuthTokenProvider tokenProvider)
 {
     _logger        = logger;
     _tokenProvider = tokenProvider;
 }
コード例 #2
0
 public GitHubController(
     ILogger <GitHubController> logger,
     OAuthTokenProvider tokenProvider,
     GitHubServiceClient githubServiceClient)
 {
     _logger              = logger;
     _tokenProvider       = tokenProvider;
     _githubServiceClient = githubServiceClient;
 }
コード例 #3
0
 public AccountLinkingPrompt(
     ILogger <AccountLinkingPrompt> logger,
     IOptions <AccountLinkingPromptOptions> options,
     OAuthTokenProvider oauthTokenProvider)
 {
     _logger             = logger;
     _options            = options.Value;
     _oauthTokenProvider = oauthTokenProvider;
 }
コード例 #4
0
        public static IHttpClientBuilder AddIdentity(this IHttpClientBuilder clientBuilder, IIdentityConfig identityConfig, IOAuthTokenStrategy tokenStrategy)
        {
            clientBuilder.ConfigureHttpClient(httpClient =>
            {
                var tokenProvider = new OAuthTokenProvider(httpClient, identityConfig, tokenStrategy);

                httpClient.DefaultRequestHeaders.Add(
                    Constants.RequestAuthorizationHeader,
                    tokenProvider.GetAccessToken());
            });

            return(clientBuilder);
        }
コード例 #5
0
        public ActionResult <TokenModel> Token([FromBody] GetTokenModel model)
        {
            if (model.Username != "testuser" || model.Password != "1234567")
            {
                return(Unauthorized());
            }

            var token = OAuthTokenProvider.GetAccessToken(new TokenOptions
            {
                Identifier = model.Username
            });

            return(Created("", new TokenModel
            {
                Token = token
            }));
        }
コード例 #6
0
 public SampleActivityHandler(
     ILogger <SampleActivityHandler <TDialog> > logger,
     TDialog dialog,
     OAuthTokenProvider oAuthTokenProvider,
     GitHubServiceClient gitHubServiceClient,
     ConversationState botState,
     UserState userState,
     IDataProtectionProvider dataProtectionProvider) : base()
 {
     _logger = logger;
     _gitHubServiceClient = gitHubServiceClient;
     _oAuthTokenProvider  = oAuthTokenProvider;
     _dialog        = dialog;
     _botState      = botState;
     _userState     = userState;
     _dataProtector = dataProtectionProvider.CreateProtector(nameof(SampleActivityHandler <TDialog>));
 }
コード例 #7
0
    public MainDialog(
        ILogger <MainDialog> logger,
        AccountLinkingPrompt accountLinkingPrompt,
        GitHubServiceClient githubServiceClient,
        OAuthTokenProvider oauthTokenProvider) : base(oauthTokenProvider, nameof(MainDialog))
    {
        _logger = logger;
        _githubServiceClient = githubServiceClient;

        AddDialog(accountLinkingPrompt);
        AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new []
        {
            GetWaterfallDialogStep(accountLinkingPrompt.Id),
            TokenStepAsync,
        }));

        InitialDialogId = nameof(WaterfallDialog);
    }
コード例 #8
0
        static void Main(string[] args)
        {
            var clientId           = "";
            var tenantId           = "";
            var secret             = "";
            var scope              = "https://storage.azure.com/.default";
            var storageAccountName = "";
            var fileSystemName     = "myexamplehdfs";

            var tokenProvider = new OAuthTokenProvider(tenantId, clientId, secret, scope);
            var hdfs          = new FileSystemApi(storageAccountName, tokenProvider);

            var response = hdfs.CreateFileSystemAsync(fileSystemName).Result;

            hdfs.CreateDirectoryAsync(fileSystemName, "/demo").Wait();
            hdfs.CreateEmptyFileAsync(fileSystemName, "/demo/", "example.txt").Wait();

            var stream = new FileStream(@"C:\temp.txt", FileMode.Open, FileAccess.Read);

            hdfs.CreateFileAsync(fileSystemName, "/demo/", "mytest.txt", stream).Wait();

            var acls = new AclEntry[]
            {
                new AclEntry(
                    AclScope.Access,
                    AclType.Group,
                    "2dec2374-3c51-4743-b247-ad6f80ce4f0b",
                    (GrantType.Read | GrantType.Execute)),
                new AclEntry(
                    AclScope.Access,
                    AclType.Group,
                    "62049695-0418-428e-a5e4-64600d6d68d8",
                    (GrantType.Read | GrantType.Write | GrantType.Execute)),
                new AclEntry(
                    AclScope.Default,
                    AclType.Group,
                    "62049695-0418-428e-a5e4-64600d6d68d8",
                    (GrantType.Read | GrantType.Write | GrantType.Execute))
            };

            hdfs.SetAccessControlAsync(fileSystemName, "/", acls).Wait();
            Console.ReadLine();
        }
コード例 #9
0
 public FileSystemApi(string storageAccountName, OAuthTokenProvider tokenProvider)
 {
     this.storageAccountName = storageAccountName;
     this.tokenProvider      = tokenProvider;
     this.baseUri            = new Uri($"https://{this.storageAccountName}.dfs.core.windows.net");
 }
コード例 #10
0
        private static bool FactoryEquals(MessagingFactory factory1, MessagingFactory factory2)
        {
            bool flag;
            bool flag1;
            bool flag2;
            bool flag3;
            bool flag4;
            MessagingFactorySettings           settings      = factory1.GetSettings();
            SharedSecretTokenProvider          tokenProvider = settings.TokenProvider as SharedSecretTokenProvider;
            SharedAccessSignatureTokenProvider sharedAccessSignatureTokenProvider = settings.TokenProvider as SharedAccessSignatureTokenProvider;
            WindowsTokenProvider               windowsTokenProvider      = settings.TokenProvider as WindowsTokenProvider;
            OAuthTokenProvider                 oAuthTokenProvider        = settings.TokenProvider as OAuthTokenProvider;
            MessagingFactorySettings           messagingFactorySetting   = factory2.GetSettings();
            SharedSecretTokenProvider          sharedSecretTokenProvider = messagingFactorySetting.TokenProvider as SharedSecretTokenProvider;
            SharedAccessSignatureTokenProvider tokenProvider1            = messagingFactorySetting.TokenProvider as SharedAccessSignatureTokenProvider;
            WindowsTokenProvider               windowsTokenProvider1     = messagingFactorySetting.TokenProvider as WindowsTokenProvider;
            OAuthTokenProvider                 oAuthTokenProvider1       = messagingFactorySetting.TokenProvider as OAuthTokenProvider;

            if (settings.OperationTimeout != messagingFactorySetting.OperationTimeout)
            {
                return(false);
            }
            if (settings.TransportType != messagingFactorySetting.TransportType)
            {
                return(false);
            }
            if (tokenProvider != null || sharedSecretTokenProvider != null)
            {
                flag = (tokenProvider == null ? false : sharedSecretTokenProvider != null);
            }
            else
            {
                flag = true;
            }
            bool flag5 = flag;

            if (windowsTokenProvider != null || windowsTokenProvider1 != null)
            {
                flag1 = (windowsTokenProvider == null ? false : windowsTokenProvider1 != null);
            }
            else
            {
                flag1 = true;
            }
            bool flag6 = flag1;

            if (oAuthTokenProvider != null || oAuthTokenProvider1 != null)
            {
                flag2 = (oAuthTokenProvider == null ? false : oAuthTokenProvider1 != null);
            }
            else
            {
                flag2 = true;
            }
            bool flag7 = flag2;

            if (sharedAccessSignatureTokenProvider != null || tokenProvider1 != null)
            {
                flag3 = (sharedAccessSignatureTokenProvider == null ? false : tokenProvider1 != null);
            }
            else
            {
                flag3 = true;
            }
            bool flag8 = flag3;

            if (!flag5 || !flag6 || !flag7 || !flag8)
            {
                return(false);
            }
            if (tokenProvider != null && sharedSecretTokenProvider != null && (tokenProvider.IssuerName != sharedSecretTokenProvider.IssuerName || !tokenProvider.IssuerSecret.SequenceEqual <byte>(sharedSecretTokenProvider.IssuerSecret) || tokenProvider.IsWebTokenSupported != sharedSecretTokenProvider.IsWebTokenSupported))
            {
                return(false);
            }
            if (sharedAccessSignatureTokenProvider != null && tokenProvider1 != null)
            {
                if (sharedAccessSignatureTokenProvider.encodedSharedAccessKey != null || tokenProvider1.encodedSharedAccessKey != null)
                {
                    flag4 = (sharedAccessSignatureTokenProvider.encodedSharedAccessKey == null ? false : tokenProvider1.encodedSharedAccessKey != null);
                }
                else
                {
                    flag4 = true;
                }
                bool flag9 = flag4;
                if (sharedAccessSignatureTokenProvider.keyName != tokenProvider1.keyName || sharedAccessSignatureTokenProvider.tokenTimeToLive != tokenProvider1.tokenTimeToLive || !flag9)
                {
                    return(false);
                }
                if (sharedAccessSignatureTokenProvider.encodedSharedAccessKey != null && tokenProvider1.encodedSharedAccessKey != null)
                {
                    if ((int)sharedAccessSignatureTokenProvider.encodedSharedAccessKey.Length != (int)tokenProvider1.encodedSharedAccessKey.Length)
                    {
                        return(false);
                    }
                    if (!sharedAccessSignatureTokenProvider.encodedSharedAccessKey.SequenceEqual <byte>(tokenProvider1.encodedSharedAccessKey))
                    {
                        return(false);
                    }
                }
            }
            if (oAuthTokenProvider != null && oAuthTokenProvider1 != null && oAuthTokenProvider.IsWebTokenSupported != oAuthTokenProvider1.IsWebTokenSupported)
            {
                return(false);
            }
            if (windowsTokenProvider != null && windowsTokenProvider1 != null)
            {
                if (windowsTokenProvider.IsWebTokenSupported != windowsTokenProvider1.IsWebTokenSupported || windowsTokenProvider.stsUris.Count != windowsTokenProvider1.stsUris.Count)
                {
                    return(false);
                }
                if (windowsTokenProvider.stsUris.Where <Uri>((Uri t, int i) => t != windowsTokenProvider1.stsUris[i]).Any <Uri>())
                {
                    return(false);
                }
                if (windowsTokenProvider.credential == null && windowsTokenProvider1.credential != null || windowsTokenProvider.credential != null && windowsTokenProvider1.credential == null)
                {
                    return(false);
                }
                if (windowsTokenProvider.credential != null && windowsTokenProvider1.credential != null && (!windowsTokenProvider.credential.Domain.Equals(windowsTokenProvider1.credential.Domain, StringComparison.OrdinalIgnoreCase) || !windowsTokenProvider.credential.UserName.Equals(windowsTokenProvider1.credential.UserName, StringComparison.OrdinalIgnoreCase) || !windowsTokenProvider.credential.Password.Equals(windowsTokenProvider1.credential.Password)))
                {
                    return(false);
                }
            }
            return(factory1.Address == factory2.Address);
        }
コード例 #11
0
 public LogoutDialog(OAuthTokenProvider oauthTokenProvider, string id = nameof(LogoutDialog)) : base(id)
 {
     _oauthTokenProvider = oauthTokenProvider;
 }