- Added configuration options for Stalwart hosted mail in .env.example. - Updated Docker Compose to include Stalwart service with health checks. - Introduced new API endpoints for managing mail domains and migration projects. - Enhanced Authentik blueprints for user enrollment and post-migration security. - Updated OAuth handling for Google and Microsoft migration processes. - Improved error handling and response structures in the mail API. - Added integration tests for email claiming and migration workflows.
31 lines
641 B
Go
31 lines
641 B
Go
package migration
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"crypto/sha256"
|
|
"encoding/base64"
|
|
)
|
|
|
|
func base64URLEncode(b []byte) string {
|
|
return base64.RawURLEncoding.EncodeToString(b)
|
|
}
|
|
|
|
func sha256Sum(input string) ([]byte, error) {
|
|
sum := sha256.Sum256([]byte(input))
|
|
return sum[:], nil
|
|
}
|
|
|
|
func newPKCE() (verifier, challenge string, err error) {
|
|
b := make([]byte, 32)
|
|
if _, err := rand.Read(b); err != nil {
|
|
return "", "", err
|
|
}
|
|
verifier = base64.RawURLEncoding.EncodeToString(b)
|
|
sum, err := sha256Sum(verifier)
|
|
if err != nil {
|
|
return "", "", err
|
|
}
|
|
challenge = base64.RawURLEncoding.EncodeToString(sum)
|
|
return verifier, challenge, nil
|
|
}
|