mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-11 14:33:41 +00:00
e621224ab2
# Which Problems Are Solved - Adds infrastructure code (basic implementation, error handling, middlewares, ...) to implement the SCIM v2 interface - Adds support for the user create SCIM v2 endpoint # How the Problems Are Solved - Adds support for the user create SCIM v2 endpoint under `POST /scim/v2/{orgID}/Users` # Additional Context Part of #8140
51 lines
910 B
Go
51 lines
910 B
Go
package schemas
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
type HttpURL url.URL
|
|
|
|
func ParseHTTPURL(rawURL string) (*HttpURL, error) {
|
|
parsedURL, err := url.Parse(rawURL)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
|
|
return nil, zerrors.ThrowInvalidArgumentf(nil, "SCIM-htturl1", "HTTP URL expected, got %v", parsedURL.Scheme)
|
|
}
|
|
|
|
return (*HttpURL)(parsedURL), nil
|
|
}
|
|
|
|
func (u *HttpURL) UnmarshalJSON(data []byte) error {
|
|
var urlStr string
|
|
if err := json.Unmarshal(data, &urlStr); err != nil {
|
|
return err
|
|
}
|
|
|
|
parsedURL, err := ParseHTTPURL(urlStr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*u = *parsedURL
|
|
return nil
|
|
}
|
|
|
|
func (u *HttpURL) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(u.String())
|
|
}
|
|
|
|
func (u *HttpURL) String() string {
|
|
if u == nil {
|
|
return ""
|
|
}
|
|
|
|
return (*url.URL)(u).String()
|
|
}
|