-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref DEV-2358
- Loading branch information
Showing
17 changed files
with
576 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go.mod | ||
go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: check-if-new-version-available | ||
check-if-new-version-available: | ||
@cp ./go.mod.tpl ./go.mod | ||
@go mod download | ||
@# If grep matches something, it exits 0, otherwise it exits 1. | ||
@# In our case, we want to invert the exit code. | ||
go list -u -m -f '{{if .Update}}{{if not .Indirect}}{{.}}{{end}}{{end}}' all | grep "."; status_code=$$?; if [ $$status_code -eq 0 ]; then exit 1; else exit 0; fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This directory is used to run scripts which check if the listed packages having new versions. | ||
|
||
Usage | ||
|
||
```sh | ||
make check-if-new-version-available | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module github.com/authgear/authgear-server/packagetracker | ||
|
||
// go1.21 supports toolchain | ||
// See https://go.dev/doc/toolchain | ||
go 1.22.7 | ||
|
||
require ( | ||
github.com/crewjam/saml v0.4.14 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// NOTE: Copied from https://github.com/crewjam/saml/blob/1dfacaea137943953459ad09aedf007c1b92deb2/duration.go | ||
|
||
package samlprotocol | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"strconv" | ||
"strings" | ||
"time" | ||
) | ||
|
||
// Duration is a time.Duration that uses the xsd:duration format for text | ||
// marshalling and unmarshalling. | ||
type Duration time.Duration | ||
|
||
// MarshalText implements the encoding.TextMarshaler interface. | ||
func (d Duration) MarshalText() ([]byte, error) { | ||
if d == 0 { | ||
return nil, nil | ||
} | ||
|
||
out := "PT" | ||
if d < 0 { | ||
d *= -1 | ||
out = "-" + out | ||
} | ||
|
||
h := time.Duration(d) / time.Hour | ||
m := time.Duration(d) % time.Hour / time.Minute | ||
s := time.Duration(d) % time.Minute / time.Second | ||
ns := time.Duration(d) % time.Second | ||
if h > 0 { | ||
out += fmt.Sprintf("%dH", h) | ||
} | ||
if m > 0 { | ||
out += fmt.Sprintf("%dM", m) | ||
} | ||
if s > 0 || ns > 0 { | ||
out += fmt.Sprintf("%d", s) | ||
if ns > 0 { | ||
out += strings.TrimRight(fmt.Sprintf(".%09d", ns), "0") | ||
} | ||
out += "S" | ||
} | ||
|
||
return []byte(out), nil | ||
} | ||
|
||
const ( | ||
day = 24 * time.Hour | ||
month = 30 * day // Assumed to be 30 days. | ||
year = 365 * day // Assumed to be non-leap year. | ||
) | ||
|
||
var ( | ||
durationRegexp = regexp.MustCompile(`^(-?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(.+))?$`) | ||
durationTimeRegexp = regexp.MustCompile(`^(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?$`) | ||
) | ||
|
||
// UnmarshalText implements the encoding.TextUnmarshaler interface. | ||
// | ||
//nolint:gocognit | ||
func (d *Duration) UnmarshalText(text []byte) error { | ||
if text == nil { | ||
*d = 0 | ||
return nil | ||
} | ||
|
||
var ( | ||
out time.Duration | ||
sign time.Duration = 1 | ||
) | ||
match := durationRegexp.FindStringSubmatch(string(text)) | ||
if match == nil || strings.Join(match[2:6], "") == "" { | ||
return fmt.Errorf("invalid duration (%s)", text) | ||
} | ||
if match[1] == "-" { | ||
sign = -1 | ||
} | ||
if match[2] != "" { | ||
y, err := strconv.Atoi(match[2]) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration years (%s): %s", text, err) | ||
} | ||
out += time.Duration(y) * year | ||
} | ||
if match[3] != "" { | ||
m, err := strconv.Atoi(match[3]) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration months (%s): %s", text, err) | ||
} | ||
out += time.Duration(m) * month | ||
} | ||
if match[4] != "" { | ||
d, err := strconv.Atoi(match[4]) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration days (%s): %s", text, err) | ||
} | ||
out += time.Duration(d) * day | ||
} | ||
if match[5] != "" { | ||
match := durationTimeRegexp.FindStringSubmatch(match[5]) | ||
if match == nil { | ||
return fmt.Errorf("invalid duration (%s)", text) | ||
} | ||
if match[1] != "" { | ||
h, err := strconv.Atoi(match[1]) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration hours (%s): %s", text, err) | ||
} | ||
out += time.Duration(h) * time.Hour | ||
} | ||
if match[2] != "" { | ||
m, err := strconv.Atoi(match[2]) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration minutes (%s): %s", text, err) | ||
} | ||
out += time.Duration(m) * time.Minute | ||
} | ||
if match[3] != "" { | ||
s, err := strconv.ParseFloat(match[3], 64) | ||
if err != nil { | ||
return fmt.Errorf("invalid duration seconds (%s): %s", text, err) | ||
} | ||
out += time.Duration(s * float64(time.Second)) | ||
} | ||
} | ||
|
||
*d = Duration(sign * out) | ||
return nil | ||
} |
Oops, something went wrong.