コード例 #1
0
 public PaymentGatewayController(IAuthorizeService authorizeService, ICaptureService captureService, IVoidService voidService, IRefundService refundService)
 {
     _authorizeService = authorizeService;
     _captureService   = captureService;
     _voidService      = voidService;
     _refundService    = refundService;
 }
コード例 #2
0
        private void AttachUserToContext(HttpContext context, IAuthorizeService autheticateService, IUserService userService, string token)
        {
            try
            {
                var tokenHandler = new JwtSecurityTokenHandler();
                var key          = Encoding.ASCII.GetBytes(_appSettings.Key);
                tokenHandler.ValidateToken(token, new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false,
                    // set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later)
                    ClockSkew = TimeSpan.Zero
                }, out SecurityToken validatedToken);

                var jwtToken = (JwtSecurityToken)validatedToken;
                var userId   = int.Parse(jwtToken.Claims.First(x => x.Type == "id").Value);

                // attach user to context on successful jwt validation
                // To DO: Get user from service
                context.Items["User"] = userService.GetById(userId);
            }
            catch (Exception e)
            {
                // do nothing if jwt validation fails
                // user is not attached to context so request won't have access to secure routes
            }
        }
コード例 #3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="appSetgings"><see cref="IAppSettings"/></param>
 /// <param name="authorizeService"><see cref="IAuthorizeService"/></param>
 public TokenController(
     IAppSettings appSetgings,
     IAuthorizeService authorizeService)
 {
     _appSetgings      = appSetgings;
     _authorizeService = authorizeService;
 }
コード例 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="questionRepo"></param>
 public QuestionsController(
     IQuestionRepository questionRepo,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _questionRepo     = questionRepo;
     _authorizeService = authorizeService;
 }
コード例 #5
0
 public LoginController(ITokenBuilder tokenBuilder, ILogger <LoginController> logger, IAuthorizeService authorizeService, IOptionsMonitor <AudienceViewModel> audienceModel)
 {
     _logger           = logger;
     _tokenBuilder     = tokenBuilder;
     _authorizeService = authorizeService;
     _audienceModel    = audienceModel.CurrentValue;
 }
コード例 #6
0
 public AuthorizeController(IMasterRepository masterRepo, IAuthorizeService authorizeService, IUserRepository userRepository)
 {
     _hostingEnvironment = UtilsProvider.HostingEnvironment;
     _masterRepo         = masterRepo;
     _authorizeService   = authorizeService;
     _UserRepository     = userRepository;
 }
コード例 #7
0
 public MenuController(
     IMenuRepository menuRepo,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _menuRepo         = menuRepo;
     _authorizeService = authorizeService;
 }
コード例 #8
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            IAuthorizeService authorizeService = (IAuthorizeService)context.HttpContext.RequestServices.GetService(typeof(IAuthorizeService));
            bool result = authorizeService.AuthorizeNormal(context);

            if (!result)
            {
                switch (_authorizeAttributeType)
                {
                case AuthorizeAttributeTypes.Mvc:
                {
                    context.Result = new RedirectToActionResult("Login", "Auth", null);
                    return;
                }

                case AuthorizeAttributeTypes.Api:
                {
                    context.Result = new UnauthorizedResult();
                    return;
                }

                default:
                {
                    throw new Exception($"Unsupported AuthorizeAttributeType");
                }
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="accountService"><see cref="IAccountService"/></param>
 /// <param name="authorizeService"><see cref="IAuthorizeService"/></param>
 public AccountController(
     IAccountService accountService,
     IAuthorizeService authorizeService)
 {
     _accountService    = accountService;
     _authorizetService = authorizeService;
 }
コード例 #10
0
 public PerformanceEvaluationsController(IPerformanceEvalutionService performanceEvaluationService,
                                         IAuthorizeService authorizeService, INotificationService notificationService)
 {
     _performanceEvaluationService = performanceEvaluationService;
     _authorizeService             = authorizeService;
     _notificationService          = notificationService;
     _context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();
 }
コード例 #11
0
 public RaterService(IAuthorizeService auth, IAtomEntryRepository repo, ILogService logger,
   IRouteService router)
 {
   AuthorizeService = auth;
   AtomEntryRepository = repo;
   LogService = logger;
   RouteService = router;
 }
コード例 #12
0
 public RatingController(
     IRatingRepository ratingRepo,
     UserManager <ApplicationUser> userManager,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _ratingRepo  = ratingRepo;
     _userManager = userManager;
 }
コード例 #13
0
 public ParticipantController(
     IParticipantRepository participantRepository,
     UserManager <Domain.User.ApplicationUser> userManager,
     IAuthorizeService authorizationService) : base(authorizationService)
 {
     _participantRepository = participantRepository;
     _userManager           = userManager;
 }
コード例 #14
0
 public StylingController(
     IStyleRepository styleRepo,
     IMenuRepository menuRepo,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _styleRepo        = styleRepo;
     _authorizeService = authorizeService;
 }
コード例 #15
0
 public DictatenController(
     IDictaatRepository dictaatRepo,
     UserManager <Domain.User.ApplicationUser> userManager,
     IAuthorizeService authorizationService) : base(authorizationService)
 {
     _authorizationService = authorizationService;
     _dictaatRepo          = dictaatRepo;
     _userManager          = userManager;
 }
コード例 #16
0
 /// <summary>
 /// default constructor
 /// </summary>
 /// <param name="pollRepository"></param>
 /// <param name="userManager"></param>
 /// <param name="authorizeService"></param>
 public PollController(
     IPollRepository pollRepository,
     UserManager <ApplicationUser> userManager,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _pollRepository   = pollRepository;
     _authorizeService = authorizeService;
     _userManager      = userManager;
 }
コード例 #17
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="quizRepo"></param>
 /// <param name="userManager"></param>
 /// <param name="authorizeService"></param>
 public QuizController(
     IQuizRepository quizRepo,
     UserManager <ApplicationUser> userManager,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _userManager      = userManager;
     _quizRepo         = quizRepo;
     _authorizeService = authorizeService;
 }
コード例 #18
0
ファイル: UserController.cs プロジェクト: scsi110/WeFramework
 public UserController(IUserService userService, IAuthorizeService authorizeService, IRoleService roleService, IMapper mapper, IEncryptionService encryptionService, IWorkContext workContext)
 {
     this.userService       = userService;
     this.authorizeService  = authorizeService;
     this.roleService       = roleService;
     this.mapper            = mapper;
     this.encryptionService = encryptionService;
     this.workContext       = workContext;
 }
コード例 #19
0
 public OrganizationsController(IOrganizationTypesService organizationTypesService,
                                IOrganizationsService organizationsService, IAuthorizeService authService, ICalendarService calendarService)
 {
     _organizationTypesService = organizationTypesService;
     _organizationsService     = organizationsService ?? throw new ArgumentNullException(nameof(organizationsService));
     _authService = authService;
     _organizationsService.ValidationDictionary = new ValidationDictionary(ModelState);
     _calendarService = calendarService ?? throw new ArgumentNullException(nameof(calendarService));
 }
コード例 #20
0
 public OAuthController(
     IAuthorizeService authorizeService,
     IValidateTokenService validateTokenService,
     IGenerateTokenService generateTokenService)
 {
     _authorizeService     = authorizeService;
     _validateTokenService = validateTokenService;
     _generateTokenService = generateTokenService;
 }
コード例 #21
0
 public AssignmentController(
     IAuthorizeService authorizeService,
     IAssignmentRepository assignmentRepo,
     UserManager <Domain.User.ApplicationUser> userManager) : base(authorizeService)
 {
     _assignmentRepo   = assignmentRepo;
     _userManager      = userManager;
     _authorizeService = authorizeService;
 }
コード例 #22
0
 public PagesController(
     IPageRepository pageRepo,
     IMenuRepository menuRepo,
     IAuthorizeService authorizeService) : base(authorizeService)
 {
     _pageRepo         = pageRepo;
     _menuRepo         = menuRepo;
     _authorizeService = authorizeService;
 }
コード例 #23
0
        public ImageService(ReportContext reportContext, IAuthorizeService authorizeService)
        {
            _authorizeService = authorizeService;
            _context          = reportContext;
            String storageConnectionString =
                "DefaultEndpointsProtocol=https;AccountName=reportpictures;AccountKey=3cxwdbIYl0MBEy0Aaa0TCuUmBZ3KHmBjT2bogu/IUTsU2VPhxPo38Vi/AKXy+tQB//VKTm0VQZ7ewUqJHZGDbQ==;EndpointSuffix=core.windows.net";
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

            client = storageAccount.CreateCloudBlobClient();
        }
コード例 #24
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="options"><see cref="AuthenticationSchemeOptions"/></param>
 /// <param name="logger"><see cref="ILoggerFactory"/></param>
 /// <param name="encoder"><see cref="UrlEncoder"/></param>
 /// <param name="clock"><see cref="ISystemClock"/></param>
 /// <param name="authorizeService"><see cref="IAuthorizeService"/></param>
 public BearerAuthenticationHandler(
     IOptionsMonitor <AuthenticationSchemeOptions> options,
     ILoggerFactory logger,
     UrlEncoder encoder,
     ISystemClock clock,
     IAuthorizeService authorizeService)
     : base(options, logger, encoder, clock)
 {
     _logger           = logger.CreateLogger <BearerAuthenticationHandler>();
     _authorizeService = authorizeService;
 }
コード例 #25
0
        public async Task Invoke(HttpContext context, IAuthorizeService autheticateService, IUserService userService)
        {
            var token = context.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();

            if (token != null)
            {
                AttachUserToContext(context, autheticateService, userService, token);
            }

            await _next(context);
        }
コード例 #26
0
 public BlogMLService(IAppServiceRepository svcRepo, IAtomPubService atompub, IAnnotateService annotate,
   IUserRepository usersRepo, IAuthorizeService auth, ILogService logger)
 {
   AppServiceRepository = svcRepo;
   AtomPubService = atompub;
   AnnotateService = annotate;
   UserRepository = usersRepo;
   AuthorizeService = auth;
   LogService = logger;
   progress = new Progress();
 }
コード例 #27
0
 public AccountService(IManageProjectRepository manageProjectRepository, ISystemsRepository systemsRepository, AspNetUsersRepository aspNetUsersRepository, AspNetUserRolesRepository aspNetUserRolesRepository, AspNetUserTokensRepository aspNetUserTokensRepo, /*ResoUserIntManager userManager*/ LogService logService, AspNetUsersService aspNetUsersService, AccountRepository repo, AccountServiceModel model, IAuthorizeService IAuthorizeService) : base(repo, model)
 {
     _aspNetUserRolesRepository = aspNetUserRolesRepository;
     _systemsRepository         = systemsRepository;
     _manageProjectRepository   = manageProjectRepository;
     _aspNetUsersRepository     = aspNetUsersRepository;
     _aspNetUserTokensRepo      = aspNetUserTokensRepo;
     //_userManager = userManager;
     log = logService;
     _aspNetUsersService = aspNetUsersService;
     _IAuthorizeService  = IAuthorizeService;
 }
コード例 #28
0
 public AdminService(IAtomPubService atompub, IAnnotateService anno, IAuthorizeService auth,
   ILogService logger, IRouteService route, IThemeService themeSvc, IAppServiceRepository svcRepo)
 {
   AtomPubService = atompub;
   AnnotateService = anno;
   AuthorizeService = auth;
   RouteService = route;
   LogService = logger;
   ThemeService = themeSvc;
   AppServiceRepository = svcRepo;
   atompub.SettingEntryLinks += (e) => SetLinks(e);
 }
コード例 #29
0
 public MasterController(IAuthorizeService authorizeService, IUnitOfWork unitOfWork, IMasterRepository masterRepository)
 {
     _hostingEnvironment = UtilsProvider.HostingEnvironment;
     _config             = UtilsProvider.Config;
     _appSetting         = UtilsProvider.AppSetting;
     _unitOfWork         = unitOfWork;
     // ------------- แบบนี้จะอ้าง ถึง Repo ตรงๆ ไม่รอรับการทำ AutoMate-Test ได้
     //_masterRepository = new MasterRepository(_hostingEnvironment, _config);
     // ------------- ควรใช้แบบนี้
     _masterRepository = masterRepository;
     _authorizeService = authorizeService;
 }
コード例 #30
0
        public ShellViewModel(INavigationService navigationService, IAuthorizeService authorizeService)
        {
            this.navigationService = navigationService;
            this.authorizeService  = authorizeService;

            authorizeService.AuthenticatedChanged += AuthorizeService_AuthenticatedChanged;


            //ShowVehiclesCommand = new RelayCommand(() => ShowVehicles());
            //ShowEmployeesCommand = new RelayCommand(() => ShowEmployees());

            ShowViewCommand = new RelayCommand <string>(p => ShowView(p));
        }
コード例 #31
0
ファイル: Grant.cs プロジェクト: Meytol/Foodtopia
        public Grant(IHttpContextAccessor httpContextAccessor, IAuthenticationCookieService authCookieService, IAuthenticationSessionService authSessionService, IAuthorizeService authorizeService,
                     AuthorizeLevel grantType = AuthorizeLevel.NeedAuthorize, GrantPriority grantPriority = GrantPriority.Default)
        {
            _httpContextAccessor = httpContextAccessor;
            _authCookieService   = authCookieService;
            _authSessionService  = authSessionService;
            _authorizeService    = authorizeService;

            _grantType               = grantType;
            _httpContext             = _httpContextAccessor.HttpContext;
            _isAuthenticationChecked = "IsAuthenticationChecked";

            _grantPriority = grantPriority;
        }
コード例 #32
0
        public LoginViewModel(IProfileRepository profileRepository,
                              INavigationService navigationService,
                              IAuthorizeService authorizeService
                              )
        {
            this.profileRepository = profileRepository;
            this.navigationService = navigationService;
            this.authorizeService  = authorizeService;

            Profiles = profileRepository.Get();

            CancelCommand = new RelayCommand(() => Cancel());
            LoginCommand  = new RelayCommand(() => Login());
        }
コード例 #33
0
    public AnnotateService(IContainer container, IAtomPubService atompub, IAppServiceRepository svcRepo, IAuthorizeService auth,
      IAtomEntryRepository entryRepo, IMediaRepository mediaRepo, ILogService logger)
    {
      AppService = svcRepo.GetService();
      AtomPubService = atompub;
      AuthorizeService = auth;
      AtomEntryRepository = entryRepo;
      MediaRepository = mediaRepo;
      Container = container;
      LogService = logger;

      atompub.SettingEntryLinks += (e) => SetLinks(e);
      atompub.SettingFeedLinks += (f) => SetLinks(f);
    }
コード例 #34
0
 public ExportController(ReportContext context, IAuthorizeService authorizeService, IImageService imageService, IEmailService emailService)
 {
     _context          = context;
     _imageService     = imageService;
     _authorizeService = authorizeService;
     _emailService     = emailService;
     _imageHandler     = new ImageHandler();
     _largeRegularFont = new XFont("Arial", 20, XFontStyle.Bold);
     _medRegularFont   = new XFont("Arial", 13, XFontStyle.Regular);
     _medBoldFont      = new XFont("Arial", 13, XFontStyle.Bold);
     _smallRegularFont = new XFont("Arial", 8, XFontStyle.Regular);
     _smallBoldFont    = new XFont("Arial", 8, XFontStyle.Bold);
     _document         = new PdfDocument();
     _color            = new XSolidBrush(XColor.FromArgb(179, 204, 204));
     _text             = new ReportText();
 }
コード例 #35
0
 public AtomPubService(
     IAppServiceRepository appServiceRepository,
     IAppCategoriesRepository appCategoriesRepository,
     IAtomEntryRepository atomEntryRepository,
     IMediaRepository mediaRepository,
     IAuthorizeService authorizeService,
     IContainer container, 
   ILogService logger)
 {
   this.AppServiceRepository = appServiceRepository;
   this.AppCategoriesRepository = appCategoriesRepository;
   this.AtomEntryRepository = atomEntryRepository;
   this.MediaRepository = mediaRepository;
   this.AuthorizeService = authorizeService;
   this.Container = container;
   this.LogService = logger;
 }
コード例 #36
0
 public BlogService(IAtomPubService atompub, IAnnotateService annotate,
   IAppServiceRepository svcRepo, IContainer container,
     IAtomEntryRepository entryRepo, IAuthorizeService auth, ILogService logger,
   ICleanContentService cleaner)
 {
   this.AppService = svcRepo.GetService();
   this.AppServiceRepository = svcRepo;
   this.AtomEntryRepository = entryRepo;
   this.Container = container;
   this.AnnotateService = annotate;
   this.AuthorizeService = auth;
   this.LogService = logger;
   this.CleanContentService = cleaner;
   atompub.CreatingEntry += OnModifyEntry;
   atompub.UpdatingEntry += OnModifyEntry;
   annotate.AnnotatingEntry += OnAnnotateEntry;
   atompub.SettingEntryLinks += (e) => SetLinks(e);
   atompub.SettingFeedLinks += (f) => SetLinks(f);
 }
コード例 #37
0
    //public static void Auth(this IAuthorizeService auth, AuthAction action)
    //{
    //  Auth(auth, null, action);
    //}

    public static void SetPerson(this AtomEntry entry, IAuthorizeService auth, bool forceAuthor)
    {
      //TODO: how to handle existing people, validate them?

      //determine if current user is an author or contributor
      User u = System.Threading.Thread.CurrentPrincipal.Identity as User;

      if (!u.IsAuthenticated) return;
      List<AtomPerson> authors = entry.Authors.ToList();
      if (auth.GetRoles(u, entry.Id.ToScope()) >= AuthRoles.Author || forceAuthor)
      {
        AtomPerson author = u.ToAtomAuthor();
        if (!authors.Contains(author))
        {
          authors.Add(author); //add
          entry.Authors = authors; //update
        }
      }
      else if (auth.GetRoles(u, entry.Id.ToScope()) >= AuthRoles.Contributor)
      {
        List<AtomPerson> contribs = entry.Contributors.ToList();
        AtomPerson contrib = u.ToAtomContributor();
        if (!contribs.Contains(contrib))
        {
          contribs.Add(contrib); //add
          entry.Contributors = contribs; //update
        }
      }
      else //default to author
      {
        AtomPerson author = u.ToAtomAuthor();
        if (!authors.Contains(author))
        {
          authors.Add(author); //add
          entry.Authors = authors; //update
        }
      }
    }
コード例 #38
0
 public static void SetPerson(this AtomEntry entry, IAuthorizeService auth)
 {
   SetPerson(entry, auth, false);
 }
コード例 #39
0
 /// <summary>
 /// Basic constructor with needed service
 /// </summary>
 /// <param name="authorizeService">The membershipService used for authenticating a member</param>
 /// <remarks>
 /// Should be created with UnityContainer and Constructor parameter injection
 /// </remarks>
 public AuthorizeController(IAuthorizeService authorizeService)
 {
     this.authorizeService = authorizeService;
 }