refactor v1, start support for more protocols and implement nak
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -1,13 +1,17 @@
|
||||
package eap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"slices"
|
||||
|
||||
"goauthentik.io/internal/outpost/radius/eap/protocol"
|
||||
)
|
||||
|
||||
type ProtocolConstructor func() protocol.Payload
|
||||
|
||||
type Settings struct {
|
||||
ProtocolsToOffer []protocol.Type
|
||||
Protocols []ProtocolConstructor
|
||||
ProtocolPriority []protocol.Type
|
||||
ProtocolSettings map[protocol.Type]interface{}
|
||||
}
|
||||
|
||||
@ -18,13 +22,23 @@ type StateManager interface {
|
||||
}
|
||||
|
||||
type State struct {
|
||||
ChallengesToOffer []protocol.Type
|
||||
TypeState map[protocol.Type]any
|
||||
Protocols []ProtocolConstructor
|
||||
ProtocolIndex int
|
||||
ProtocolPriority []protocol.Type
|
||||
TypeState map[protocol.Type]any
|
||||
}
|
||||
|
||||
func (st *State) GetNextProtocol() (protocol.Type, error) {
|
||||
if st.ProtocolIndex >= len(st.ProtocolPriority) {
|
||||
return protocol.Type(0), errors.New("no more protocols to offer")
|
||||
}
|
||||
return st.ProtocolPriority[st.ProtocolIndex], nil
|
||||
}
|
||||
|
||||
func BlankState(settings Settings) *State {
|
||||
return &State{
|
||||
ChallengesToOffer: slices.Clone(settings.ProtocolsToOffer),
|
||||
TypeState: map[protocol.Type]any{},
|
||||
Protocols: slices.Clone(settings.Protocols),
|
||||
ProtocolPriority: slices.Clone(settings.ProtocolPriority),
|
||||
TypeState: map[protocol.Type]any{},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user