fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.01k stars 418 forks source link

Add Okta auth integration #10271

Closed lukeheath closed 1 year ago

lukeheath commented 1 year ago

Tasks

params := url.Values{
    "username":   []string{email},
    "password":   []string{password},
    "scope":      []string{"openid"},
    "grant_type": []string{"password"},
}
req, err := http.NewRequestWithContext(
    ctx, "POST", OKTA_URL + "/oauth2/default/v1/token",
    strings.NewReader(params.Encode()),
)
if err != nil {
    return nil, err
}

client := http.Client{}
digest := base64.StdEncoding.EncodeToString(OKTA_APP_ID + ":" + OKTA_APP_SECRET)
req.Header.Add("Authorization", "Basic " + digest)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req)

type SaltedSHA512PBKDF2Dictionary struct {
    Iterations int    `plist:"iterations"`
    Salt       []byte `plist:"salt"`
    Entropy    []byte `plist:"entropy"`
}

const macKeyLen = 128

// saltedSHA512PBKDF2 creates a SALTED-SHA512-PBKDF2 dictionary
// from a plaintext password.
func saltedSHA512PBKDF2(plaintext string) (int, []byte, []byte, error) {
    salt := make([]byte, 32)
    if _, err := rand.Read(salt); err != nil {
        return 0, nil, nil, err
    }
    iterations, err := secureRandInt(20000, 40000)
    if err != nil {
        return 0, nil, nil, err
    }
    return iterations, salt, pbkdf2.Key([]byte(plaintext), salt, iterations, macKeyLen, sha512.New), nil
}

func secureRandInt(min, max int64) (int, error) {
    var random int
    for {
        iter, err := rand.Int(rand.Reader, big.NewInt(max))
        if err != nil {
            return 0, err
        }
        if iter.Int64() >= min {
            random = int(iter.Int64())
            break
        }
    }
    return random, nil
}
lukeheath commented 1 year ago

Hey team! Please add your planning poker estimate with Zenhub @gillespi314 @roperzh

noahtalerman commented 1 year ago

Here's the MDM command to create Mac user account (admin privileges): https://developer.apple.com/business/documentation/MDM-Protocol-Reference.pdf#accountconfiguration

lukeheath commented 1 year ago

@roperzh Heads up that we've been asked to defer finishing the Okta integration for now. Please go ahead and finish this issue since it's so close.

fleet-release commented 1 year ago

// Secure password saved // In the clouds of a glass city // Secure in Okta's arms