Skip to content

Commit

Permalink
Merge pull request #259 from Scalingo/feat/DOC-89/add_tfa_events
Browse files Browse the repository at this point in the history
feat(events): add two factor auth events
  • Loading branch information
Anouchka-M authored Jul 26, 2022
2 parents fcdfdd7 + f59b71e commit 575a487
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
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
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

0 comments on commit 575a487

Please sign in to comment.