mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Fix OIDCCallbackHandler
This commit is contained in:
parent
38533c99aa
commit
6997becdd3
1 changed files with 9 additions and 7 deletions
|
@ -254,7 +254,8 @@ func (a *AuthProviderOIDC) OIDCCallbackHandler(
|
||||||
|
|
||||||
// Register the node if it does not exist.
|
// Register the node if it does not exist.
|
||||||
if mKey != nil {
|
if mKey != nil {
|
||||||
if err := a.registerNode(user, mKey, nodeExpiry); err != nil {
|
node, err = a.registerNode(user, mKey, nodeExpiry)
|
||||||
|
if err != nil {
|
||||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -448,21 +449,22 @@ func (a *AuthProviderOIDC) registerNode(
|
||||||
user *types.User,
|
user *types.User,
|
||||||
machineKey *key.MachinePublic,
|
machineKey *key.MachinePublic,
|
||||||
expiry time.Time,
|
expiry time.Time,
|
||||||
) error {
|
) (*types.Node, error) {
|
||||||
ipv4, ipv6, err := a.ipAlloc.Next()
|
ipv4, ipv6, err := a.ipAlloc.Next()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := a.db.RegisterNodeFromAuthCallback(
|
node, err := a.db.RegisterNodeFromAuthCallback(
|
||||||
*machineKey,
|
*machineKey,
|
||||||
types.UserID(user.ID),
|
types.UserID(user.ID),
|
||||||
&expiry,
|
&expiry,
|
||||||
util.RegisterMethodOIDC,
|
util.RegisterMethodOIDC,
|
||||||
ipv4, ipv6,
|
ipv4, ipv6,
|
||||||
); err != nil {
|
)
|
||||||
return fmt.Errorf("could not register node: %w", err)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not register node: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue