diff --git a/CHANGELOG.md b/CHANGELOG.md index ce1d9436..6d57485f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## To Be Released -* feat(events): implement token related events [#257](https://github.com/Scalingo/go-scalingo/pull/256) +* feat(events): implement two factor auth related events [#259](https://github.com/Scalingo/go-scalingo/pull/259) +* feat(events): implement token related events [#257](https://github.com/Scalingo/go-scalingo/pull/257) * feat(events): implement event for the update of a key [#256](https://github.com/Scalingo/go-scalingo/pull/256) * feat(events): implement event for the update of an hds contact [#255](https://github.com/Scalingo/go-scalingo/pull/255) * feat(events): implement event for the creation of a data access consent [#255](https://github.com/Scalingo/go-scalingo/pull/255) diff --git a/events_boilerplate.go b/events_boilerplate.go index e66e96ac..cfe424ae 100644 --- a/events_boilerplate.go +++ b/events_boilerplate.go @@ -204,3 +204,11 @@ func (e *EventRegenerateTokenType) TypeDataPtr() interface{} { func (e *EventDeleteTokenType) TypeDataPtr() interface{} { return &e.TypeData } + +func (e *EventTfaEnabledType) TypeDataPtr() interface{} { + return &e.TypeData +} + +func (e *EventTfaDisabledType) TypeDataPtr() interface{} { + return &e.TypeData +} diff --git a/events_structs.go b/events_structs.go index 48762112..7fd365a0 100644 --- a/events_structs.go +++ b/events_structs.go @@ -126,6 +126,8 @@ const ( EventNewToken EventTypeName = "new_token" EventRegenerateToken EventTypeName = "regenerate_token" EventDeleteToken EventTypeName = "delete_token" + EventTfaEnabled EventTypeName = "tfa_enabled" + EventTfaDisabled EventTypeName = "tfa_disabled" // EventLinkGithub and EventUnlinkGithub events are kept for // retro-compatibility. They are replaced by SCM events. @@ -1117,6 +1119,33 @@ func (ev *EventCreateDataAccessConsentType) String() string { return res } +// Enable Tfa +type EventTfaEnabledTypeData struct { + Provider string `json:"provider"` +} + +type EventTfaEnabledType struct { + Event + TypeData EventTfaEnabledTypeData `json:"type_data"` +} + +func (ev *EventTfaEnabledType) String() string { + return fmt.Sprintf("Two factor authentication enabled by %s", ev.TypeData.Provider) +} + +// Disable Tfa +type EventTfaDisabledTypeData struct { +} + +type EventTfaDisabledType struct { + Event + TypeData EventTfaDisabledTypeData `json:"type_data"` +} + +func (ev *EventTfaDisabledType) String() string { + return "Two factor authentication disabled" +} + func (pev *Event) Specialize() DetailedEvent { var e DetailedEvent ev := *pev @@ -1243,6 +1272,10 @@ func (pev *Event) Specialize() DetailedEvent { e = &EventRegenerateTokenType{Event: ev} case EventDeleteToken: e = &EventDeleteTokenType{Event: ev} + case EventTfaEnabled: + e = &EventTfaEnabledType{Event: ev} + case EventTfaDisabled: + e = &EventTfaDisabledType{Event: ev} // Deprecated events. Replaced by equivalent with SCM in the name instead of // Github case EventLinkGithub: