-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
668 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package models | ||
|
||
type GenerateSAMLTokenRequest struct { | ||
UsernameOrEmail string `json:"username_or_email"` | ||
Password string `json:"password"` | ||
AppID string `json:"app_id"` | ||
Subdomain string `json:"subdomain"` | ||
IPAddress string `json:"ip_address,omitempty"` | ||
} | ||
|
||
type VerifyMFATokenRequest struct { | ||
AppID string `json:"app_id"` | ||
DeviceID string `json:"device_id"` | ||
StateToken string `json:"state_token"` | ||
OTPToken string `json:"otp_token,omitempty"` | ||
DoNotNotify bool `json:"do_not_notify,omitempty"` | ||
} | ||
|
||
type EnrollFactorRequest struct { | ||
FactorID int `json:"factor_id"` | ||
DisplayName string `json:"display_name"` | ||
ExpiresIn string `json:"expires_in,omitempty"` | ||
Verified bool `json:"verified,omitempty"` | ||
RedirectTo string `json:"redirect_to,omitempty"` | ||
CustomMessage string `json:"custom_message,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package onelogin | ||
|
||
import utl "github.com/onelogin/onelogin-go-sdk/internal/utilities" | ||
|
||
const ( | ||
GroupsPath = "api/1/groups" | ||
) | ||
|
||
func (sdk *OneloginSDK) GetGroupByID(groupID int) (interface{}, error) { | ||
p, err := utl.BuildAPIPath(GroupsPath, groupID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, err := sdk.Client.Get(&p, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return utl.CheckHTTPResponse(resp) | ||
} | ||
|
||
func (sdk *OneloginSDK) GetGroups() (interface{}, error) { | ||
p := GroupsPath | ||
resp, err := sdk.Client.Get(&p, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return utl.CheckHTTPResponse(resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package onelogin | ||
|
||
import ( | ||
"github.com/onelogin/onelogin-go-sdk/internal/models" | ||
utl "github.com/onelogin/onelogin-go-sdk/internal/utilities" | ||
) | ||
|
||
const ( | ||
MFAPath string = "api/2/mfa/users" | ||
) | ||
|
||
// https://<subdomain>/api/2/mfa/users/<user_id>/factors | ||
func (sdk *OneloginSDK) GetAuthFactors(userID int) (interface{}, error) { | ||
p, err := utl.BuildAPIPath(MFAPath, userID, "factors") | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, err := sdk.Client.Get(&p, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return utl.CheckHTTPResponse(resp) | ||
} | ||
|
||
// https://<subdomain>/api/2/mfa/users/<user_id>/registrations | ||
func (sdk *OneloginSDK) EnrollMFAFactor(factor models.EnrollFactorRequest, userID int) (interface{}, error) { | ||
p, err := utl.BuildAPIPath(MFAPath, userID, "registrations") | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, err := sdk.Client.Post(&p, factor) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return utl.CheckHTTPResponse(resp) | ||
} | ||
|
||
// https://<subdomain>/api/2/mfa/users/<user_id>/registrations/<registration_id> | ||
func (sdk *OneloginSDK) VerifyMFAEnrollment(userID, registrationID, otp int) (interface{}, error) { | ||
p, err := utl.BuildAPIPath(MFAPath, userID, "registrations", registrationID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, err := sdk.Client.Put(&p, otp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return utl.CheckHTTPResponse(resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.