public ConsentController(
     IIdentityServerInteractionService interaction,
     IEventService events,
     ILogger <ConsentController> logger)
 {
     consent = new ConsentService(interaction, events, logger);
 }
 public IndexModel(IIdentityServerInteractionService interaction,
                   IClientStore clientStore,
                   IResourceStore resourceStore,
                   ILoggingServices loggingServices)
 {
     _consent = new ConsentService <IndexModel>(interaction, clientStore, resourceStore, HttpContext, loggingServices);
 }
        public async void ShouldReturnListOfConsentsForUserId()
        {
            var userId      = "some-user-id";
            var accessToken = "at-raw1";

            var mConfig = new Mock <IConfiguration>();

            var mConsentRepo = new Mock <IRepository <Consent, string> >();
            var consents     = new List <Consent>(new Consent[]
            {
                new Consent()
                {
                    ConnectorId = "connector-id1", ConsentId = "consent-id1", AccessTokenRaw = accessToken
                },
            });

            mConsentRepo.Setup(x => x.GetAll(userId)).Returns(consents);

            var mTlApi = new Mock <ITrueLayerDataApi>();

            var consentService = new ConsentService(mConfig.Object, mConsentRepo.Object, mTlApi.Object);

            var result = consentService.GetConsents(userId);

            Assert.Equal(consents, result);
        }
示例#4
0
        public void ShouldReturnAuthorisationUrlWithCorrectStateValue()
        {
            var userId = "test-user";

            var mLogger = new Mock <ILogger <ConsentController> >();

            var config = new Mock <IConfiguration>();

            config.SetupGet(x => x["authorisationUrl"]).Returns("<enter_long_authorisation_url_here>");

            var mConsentRepo      = new Mock <IRepository <Consent, string> >();
            var mTrueLayerDataApi = new Mock <ConcreteTrueLayerDataApi>(config.Object);

            var mConsentService = new ConsentService(config.Object, mConsentRepo.Object, mTrueLayerDataApi.Object);

            var mAcctRepo = new Mock <IRepository <List <Account>, string> >();
            var accts     = new List <Account>();

            mAcctRepo.Setup(x => x.Unused()).Returns(false);
            mAcctRepo.Setup(x => x.Get(userId)).Returns(accts);
            var mTxnRepo = new Mock <ITransactionRepository <Transaction, string> >();

            var acctService = new AccountService(mTrueLayerDataApi.Object, mConsentService, mAcctRepo.Object, mTxnRepo.Object);

            var consentController = new ConsentController(mLogger.Object, mConsentService, acctService, mTrueLayerDataApi.Object);

            var response = consentController.Authorise(userId);

            Assert.Equal($"{config.Object["authorisationUrl"]}&state={userId}", response.AuthorisationUrl);
        }
示例#5
0
        private static async Task ModifyHtmlOutput(MemoryStream bufferBody, Stream originalBody, IOwinContext owinContext)
        {
            var consentService = new ConsentService(new CookieStorage(owinContext));

            bufferBody.Seek(0, SeekOrigin.Begin);
            var reader        = new StreamReader(bufferBody);
            var stringBuilder = new StringBuilder(await reader.ReadToEndAsync());

            var content = "<script src=\""
                          + _settings.JavascriptFileLocation + "\"></script>"
                          + consentService.RenderNotificationHtml(_settings, _cachedHtmlContent, _cultureCallback(owinContext.Request), false)
                          + "</body>";

            stringBuilder.Replace("</body>", content);

            using (var memoryStream = new MemoryStream(stringBuilder.Length))
            {
                var streamWriter = new StreamWriter(memoryStream);
                streamWriter.Write(stringBuilder.ToString());
                streamWriter.Flush();
                memoryStream.Seek(0, SeekOrigin.Begin);

                await memoryStream.CopyToAsync(originalBody);
            }
        }
示例#6
0
 public ConsentController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IResourceStore resourceStore,
     ILogger <ConsentController> logger)
 {
     _consent = new ConsentService(interaction, clientStore, resourceStore, logger);
 }
 public ConsentController(IResourceStore resourceStore, IClientStore clientStore, IIdentityServerInteractionService identityServerInteractionService,
                          ConsentService consentService)
 {
     _resourceStore = resourceStore;
     _clientStore   = clientStore;
     _identityServerInteractionService = identityServerInteractionService;
     this._consentService = consentService;
 }
示例#8
0
        public ConsentModel(IIdentityServerInteractionService interaction, IClientStore clientStore, IResourceStore resourceStore)
        {
            _interaction   = interaction;
            _clientStore   = clientStore;
            _resourceStore = resourceStore;

            _consentServ = new ConsentService(_interaction, _clientStore, _resourceStore);
        }
示例#9
0
 public ConsentController(
     ILogger <Logger> logger,
     Config config,
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IResourceStore resourceStore) : base(logger, config)
 {
     _consent = new ConsentService(interaction, clientStore, resourceStore, logger);
 }
示例#10
0
 public ConsentController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IResourceStore resourceStore,
     ILogger <ConsentController> logger,
     TenantService _tenantService,
     TenantDbContext _tenantDb)
 {
     _consent      = new ConsentService(interaction, clientStore, resourceStore, logger);
     tenantService = _tenantService;
     tenantDb      = _tenantDb;
 }
示例#11
0
        public async void ShouldProcessCallback()
        {
            var state       = "some-user-id";
            var accessToken = "at-raw1";
            var code        = "some random code";

            var mConfig = new Mock <IConfiguration>();
            var mLogger = new Mock <ILogger <ConsentController> >();

            var mConsentRepo = new Mock <IRepository <Consent, string> >();
            var consents     = new List <Consent>(new Consent[]
            {
                new Consent()
                {
                    ConnectorId = "connector-id1", ConsentId = "consent-id1", AccessTokenRaw = accessToken
                },
            });

            mConsentRepo.Setup(x => x.GetAll(state)).Returns(consents);

            var mTlApi        = new Mock <ITrueLayerDataApi>();
            var tlAccessToken = new TrueLayerAccessToken()
            {
                AccessToken  = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjE0NTk4OUIwNTdDOUMzMzg0MDc4MDBBOEJBNkNCOUZFQjMzRTk1MTAiLCJ0eXAiOiJhdCtqd3QiLCJ4NXQiOiJGRm1Kc0ZmSnd6aEFlQUNvdW15NV9yTS1sUkEifQ.eyJuYmYiOjE1ODU2OTg0MjgsImV4cCI6MTU4NTcwMjAyOCwiaXNzIjoiaHR0cHM6Ly9hdXRoLnRydWVsYXllci5jb20iLCJhdWQiOlsiaHR0cHM6Ly9hdXRoLnRydWVsYXllci5jb20vcmVzb3VyY2VzIiwiaW5mb19hcGkiLCJhY2NvdW50c19hcGkiLCJ0cmFuc2FjdGlvbnNfYXBpIiwiYmFsYW5jZV9hcGkiLCJjYXJkc19hcGkiLCJkaXJlY3RfZGViaXRzX2FwaSIsInN0YW5kaW5nX29yZGVyc19hcGkiXSwiY2xpZW50X2lkIjoiZXhhbXBsZWFwcGxpY2F0aW9uLXRwcnQiLCJzdWIiOiJJYzZiVi8zQWUzN0hTNnRCY3pzbm5MUURCL2RqY3FzN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kwaLJ-4AftoTtGoUL8_bWpy2RDxMIg9GvVsMEvHJv5rCs9BeMbACMEZJFEU0-S_-6w6ylkcn3odWPovKoLe8tw",
                ExpiresIn    = 3600,
                RefreshToken = "some refresh token",
                TokenType    = "type"
            };

            mTlApi.Setup(x => x.GetAccessTokenAsync(code, state)).Returns(Task.FromResult(tlAccessToken));

            var mAcctRepo = new Mock <IRepository <List <Account>, string> >();
            var accounts  = new List <Account>();

            var mTxnRepo = new Mock <ITransactionRepository <Transaction, string> >();

            var consentService    = new ConsentService(mConfig.Object, mConsentRepo.Object, mTlApi.Object);
            var accountService    = new AccountService(mTlApi.Object, consentService, mAcctRepo.Object, mTxnRepo.Object);
            var consentController = new ConsentController(mLogger.Object, consentService, accountService, mTlApi.Object);

            var request = new AuthorisationCallbackRequest
            {
                Code  = code,
                Scope = "scope",
                State = state
            };
            var response = await consentController.Callback(request);

            Assert.Equal("Success - Consent to ob-monzo granted.", response.Message);
        }
示例#12
0
 public ConsentController(ConsentService consentSvc)
 {
     _consentSvc = consentSvc;
 }
示例#13
0
 public ConsentController(ILoggerFactory loggerFactory, ConsentService consent)
 {
     _consent = consent;
     _logger  = loggerFactory.CreateLogger <ConsentController>();
 }
示例#14
0
 public ConsentController(ConsentService consent)
 {
     _consent = consent;
 }
示例#15
0
 public ConsentController(ConsentService consentServices)
 {
     this._consentServices = consentServices;
 }
示例#16
0
 public ConsentController(ConsentService consentService)
 {
     _consentService = consentService;
 }
示例#17
0
 public Swedbank(string appId)
 {
     Consent  = new ConsentService(appId);
     Accounts = new AccountService(appId);
 }
 /// <summary>   Constructor. </summary>
 /// <param name="interactionService">   The interaction service. </param>
 /// <param name="clientStore">          The client store. </param>
 /// <param name="resourceStore">        The resource store. </param>
 /// <param name="grantStore">           The grant store. </param>
 /// <param name="localizer">            The localizer. </param>
 public IdentityController(IIdentityServerInteractionService interactionService, IClientStore clientStore,
                           IResourceStore resourceStore, IPersistedGrantStore grantStore, IStringLocalizer <ConsentOptions> localizer)
 {
     _consentService = new ConsentService(interactionService, clientStore, resourceStore, grantStore, localizer);
 }
示例#19
0
 private AspnetCookieConsent(IFileShim fileShim, ConsentService consentService)
 {
     _fileShim       = fileShim;
     _consentService = consentService;
 }