mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 15:00:51 +02:00
frontend: react+mui (#3004)
* mui v5 wip * wip * wip * wip * use compressor for all controlplane endpoints * wip * wip * add deps * fix authenticate URL * fix test * fix test * fix build * maybe fix build * fix integration test * remove image asset test * add yarn.lock
This commit is contained in:
parent
64d8748251
commit
2824faecbf
84 changed files with 13373 additions and 1455 deletions
62
internal/urlutil/known.go
Normal file
62
internal/urlutil/known.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package urlutil
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// DefaultDeviceType is the default device type when none is specified.
|
||||
const DefaultDeviceType = "any"
|
||||
|
||||
// RedirectURL returns the redirect URL from the query string or a cookie.
|
||||
func RedirectURL(r *http.Request) (string, bool) {
|
||||
if v := r.FormValue(QueryRedirectURI); v != "" {
|
||||
return v, true
|
||||
}
|
||||
|
||||
if c, err := r.Cookie(QueryRedirectURI); err == nil {
|
||||
return c.Value, true
|
||||
}
|
||||
|
||||
return "", false
|
||||
}
|
||||
|
||||
// SignOutURL returns the /.pomerium/sign_out URL.
|
||||
func SignOutURL(r *http.Request, authenticateURL *url.URL, key []byte) string {
|
||||
u := authenticateURL.ResolveReference(&url.URL{
|
||||
Path: "/.pomerium/sign_out",
|
||||
})
|
||||
if redirectURI, ok := RedirectURL(r); ok {
|
||||
u.RawQuery = (&url.Values{
|
||||
QueryRedirectURI: {redirectURI},
|
||||
}).Encode()
|
||||
}
|
||||
return NewSignedURL(key, u).Sign().String()
|
||||
}
|
||||
|
||||
// WebAuthnURL returns the /.pomerium/webauthn URL.
|
||||
func WebAuthnURL(r *http.Request, authenticateURL *url.URL, key []byte, values url.Values) string {
|
||||
u := authenticateURL.ResolveReference(&url.URL{
|
||||
Path: "/.pomerium/webauthn",
|
||||
RawQuery: buildURLValues(values, url.Values{
|
||||
QueryDeviceType: {DefaultDeviceType},
|
||||
QueryEnrollmentToken: nil,
|
||||
QueryRedirectURI: {authenticateURL.ResolveReference(&url.URL{
|
||||
Path: "/.pomerium/device-enrolled",
|
||||
}).String()},
|
||||
}).Encode(),
|
||||
})
|
||||
return NewSignedURL(key, u).Sign().String()
|
||||
}
|
||||
|
||||
func buildURLValues(values, defaults url.Values) url.Values {
|
||||
result := make(url.Values)
|
||||
for k, vs := range defaults {
|
||||
if values.Has(k) {
|
||||
result[k] = values[k]
|
||||
} else if vs != nil {
|
||||
result[k] = vs
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue