Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(events): add two factor auth events #259

Merged
merged 3 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions events_boilerplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
33 changes: 33 additions & 0 deletions events_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1117,6 +1119,33 @@ func (ev *EventCreateDataAccessConsentType) String() string {
return res
}

// Enable Tfa
EtienneM marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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:
Expand Down