Beispiel #1
0
        public async Task <ITokenValidationResult> VerifyTokenAsync(string token, SupportedTokenTypes tokenType, bool fireEvent = true)
        {
            switch (tokenType)
            {
            case SupportedTokenTypes.Bearer:
                return(await this.VerifyBearerTokenAsync(token, fireEvent));

            case SupportedTokenTypes.Basic:
                return(await this.VerifyBasicTokenAsync(token, fireEvent));

            default:
                throw ErtisAuthException.UnsupportedTokenType();
            }
        }
Beispiel #2
0
        public static bool TryParseTokenType(string tokenType, out SupportedTokenTypes supportedTokenType)
        {
            switch (tokenType)
            {
            case "Bearer":
                supportedTokenType = SupportedTokenTypes.Bearer;
                return(true);

            case "Basic":
                supportedTokenType = SupportedTokenTypes.Basic;
                return(true);

            default:
                supportedTokenType = SupportedTokenTypes.None;
                return(false);
            }
        }
Beispiel #3
0
        public async Task <User> WhoAmIAsync(string token, SupportedTokenTypes tokenType)
        {
            switch (tokenType)
            {
            case SupportedTokenTypes.Bearer:
                await this.VerifyBearerTokenAsync(token, false);

                break;

            case SupportedTokenTypes.Basic:
                await this.VerifyBasicTokenAsync(token, false);

                break;

            default:
                throw ErtisAuthException.UnsupportedTokenType();
            }

            return(await this.GetTokenOwnerAsync(token));
        }