Exemple #1
0
        public static dynamic UpdateCustomer(Customer oCustomer)
        {
            var uc            = new CustomerUpdate(oCustomer);
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users/{oCustomer.Id}", JsonHelper.JsonContent(uc), _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }
Exemple #2
0
        public static dynamic AddNewCustomer(Customer oCustomer)
        {
            var oNewCustomer  = new CustomerAdd(oCustomer);
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users?activate=true", JsonHelper.JsonContent(oNewCustomer), _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }
        public static dynamic AddNewUser(LoginViewModel model)
        {
            var oProfile = new Profile
            {
                Email     = model.UserName,
                Login     = model.UserName,
                FirstName = "No",
                LastName  = "Name"
                            //First & Last name is currently required, either pass them in or set fake name
                            //Okta is removing this requirement soon and it won't required
            };
            var oAddCustomer = new CustomerAdd();

            oAddCustomer.Profile = oProfile;

            //Enhancement:
            //could look up a group and add group to the CustomerAdd object to organize users for this app

            //Please Note:
            //User will be in 'Pending user action', which is good for security
            //can still add MFA to 'Pending' users and they can't log into Okta
            //If you want them to be Activated then set the Password

            return(JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users?activate=true", JsonHelper.JsonContent(oAddCustomer), _oktaToken));
        }
Exemple #4
0
        public static TokenIntrospectionResponse IntrospectToken(string token)
        {
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/oauth2/{_oktaOAuthIssuerId}/v1/introspect?token={token}&token_type_hint=access_token", null, null, _oktaOAuthHeaderAuth);

            if (string.IsNullOrEmpty(sJsonResponse))
            {
                return(null);
            }
            return(JsonConvert.DeserializeObject <TokenIntrospectionResponse>(sJsonResponse));
        }
        public static dynamic VerifyUserSMS(SMSViewModel model)
        {
            var oCode = new SendSMSPassCode();

            oCode.PassCode = model.PassCode;

            var sJsonResponse = JsonHelper.Post(model.ApiUrl, JsonHelper.JsonContent(oCode), _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }
        public static dynamic EnrollUserSMS(SMSViewModel model)
        {
            var oEnrollSMS = new EnrollSMS();

            oEnrollSMS.Profile.PhoneNumber = String.Format("+{0}-{1}", model.CountryCode, model.PhoneNumber);//Format - "+1-2223334444"

            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users/{model.UserId}/factors", JsonHelper.JsonContent(oEnrollSMS), _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }
Exemple #7
0
        public static OIDCTokenResponse GetToken(string oktaAuthCode)
        {
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/oauth2/{_oktaOAuthIssuerId}/v1/token?code={oktaAuthCode}&grant_type=authorization_code&redirect_uri={_oktaOAuthRedirectUri}", null, null, _oktaOAuthHeaderAuth);

            if (string.IsNullOrEmpty(sJsonResponse))
            {
                return(null); //TODO: add error handling
            }

            return(JsonConvert.DeserializeObject <OIDCTokenResponse>(sJsonResponse));
        }
        public static dynamic ActivateUserSMS(SMSViewModel model)
        {
            var oActivateVerifySMS = new ActivateVerifySMS();


            //   api/v1/users/${userId}/factors/${factorId}/lifecycle/activate
            //   api/v1/users/${userId}/factors/${factorId}/verify

            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users/{model.UserId}/factors", JsonHelper.JsonContent(oActivateVerifySMS), _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }
Exemple #9
0
        public static OktaSessionResponse SendBasicLogin(LoginViewModel login)
        {
            //create simple class to lowecase & minimize model for json - case sensitive
            var ologin = new Login
            {
                username = login.UserName,
                password = login.Password
            };

            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/authn", JsonHelper.JsonContent(ologin));

            return(JsonConvert.DeserializeObject <OktaSessionResponse>(sJsonResponse));
        }
Exemple #10
0
 public static void RevokeToken(string token)
 {
     var response = JsonHelper.Post($"https://{_apiUrlBase}/oauth2/{_oktaOAuthIssuerId}/v1/revoke?token={token}&token_type_hint=access_token", null, null, _oktaOAuthHeaderAuth);
 }
Exemple #11
0
        public static OIDCTokenResponse GetToken()
        {
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/oauth2/{_oktaOAuthIssuerId}/v1/token?grant_type=client_credentials&redirect_uri={_oktaOAuthRedirectUri}&scope=crud", _oktaOAuthHeaderAuth);

            return(JsonConvert.DeserializeObject <OIDCTokenResponse>(sJsonResponse));
        }
Exemple #12
0
        public static dynamic AddNewCustomer(Customer oCustomer)
        {
            var oNewCustomer = new CustomerAdd(oCustomer);

            return(JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users?activate=true", JsonHelper.JsonContent(oNewCustomer), _oktaToken));;
        }
        public static dynamic SendUserSMS(SMSViewModel model, string factorId)
        {
            var sJsonResponse = JsonHelper.Post($"https://{_apiUrlBase}/api/v1/users/{model.UserId}/factors/{factorId}/verify", "{}", _oktaToken);

            return(JsonConvert.DeserializeObject(sJsonResponse));
        }