repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pquerna/ffjson | inception/writerstack.go | Last | func (w *ConditionalWrite) Last() string {
if len(w.Queued) == 0 {
return ""
}
return w.Queued[len(w.Queued)-1]
} | go | func (w *ConditionalWrite) Last() string {
if len(w.Queued) == 0 {
return ""
}
return w.Queued[len(w.Queued)-1]
} | [
"func",
"(",
"w",
"*",
"ConditionalWrite",
")",
"Last",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"w",
".",
"Queued",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"w",
".",
"Queued",
"[",
"len",
"(",
"w",
".",
"Queued"... | // Last will return the last added write | [
"Last",
"will",
"return",
"the",
"last",
"added",
"write"
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/inception/writerstack.go#L24-L29 | train |
pquerna/ffjson | inception/writerstack.go | WriteFlush | func (w *ConditionalWrite) WriteFlush(s string) string {
w.Write(s)
return w.Flush()
} | go | func (w *ConditionalWrite) WriteFlush(s string) string {
w.Write(s)
return w.Flush()
} | [
"func",
"(",
"w",
"*",
"ConditionalWrite",
")",
"WriteFlush",
"(",
"s",
"string",
")",
"string",
"{",
"w",
".",
"Write",
"(",
"s",
")",
"\n",
"return",
"w",
".",
"Flush",
"(",
")",
"\n",
"}"
] | // WriteFlush will add a string and return the Flush result for the queue | [
"WriteFlush",
"will",
"add",
"a",
"string",
"and",
"return",
"the",
"Flush",
"result",
"for",
"the",
"queue"
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/inception/writerstack.go#L54-L57 | train |
pquerna/ffjson | inception/writerstack.go | GetQueued | func (w *ConditionalWrite) GetQueued() string {
t := w.Queued
s := w.Flush()
w.Queued = t
return s
} | go | func (w *ConditionalWrite) GetQueued() string {
t := w.Queued
s := w.Flush()
w.Queued = t
return s
} | [
"func",
"(",
"w",
"*",
"ConditionalWrite",
")",
"GetQueued",
"(",
")",
"string",
"{",
"t",
":=",
"w",
".",
"Queued",
"\n",
"s",
":=",
"w",
".",
"Flush",
"(",
")",
"\n",
"w",
".",
"Queued",
"=",
"t",
"\n",
"return",
"s",
"\n",
"}"
] | // GetQueued will return the current queued content without flushing. | [
"GetQueued",
"will",
"return",
"the",
"current",
"queued",
"content",
"without",
"flushing",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/inception/writerstack.go#L60-L65 | train |
pquerna/ffjson | ffjson/decoder.go | Decode | func (d *Decoder) Decode(data []byte, v interface{}) error {
f, ok := v.(unmarshalFaster)
if ok {
if d.fs == nil {
d.fs = fflib.NewFFLexer(data)
} else {
d.fs.Reset(data)
}
return f.UnmarshalJSONFFLexer(d.fs, fflib.FFParse_map_start)
}
um, ok := v.(json.Unmarshaler)
if ok {
return um.UnmarshalJSON(data)
}
return json.Unmarshal(data, v)
} | go | func (d *Decoder) Decode(data []byte, v interface{}) error {
f, ok := v.(unmarshalFaster)
if ok {
if d.fs == nil {
d.fs = fflib.NewFFLexer(data)
} else {
d.fs.Reset(data)
}
return f.UnmarshalJSONFFLexer(d.fs, fflib.FFParse_map_start)
}
um, ok := v.(json.Unmarshaler)
if ok {
return um.UnmarshalJSON(data)
}
return json.Unmarshal(data, v)
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"Decode",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"f",
",",
"ok",
":=",
"v",
".",
"(",
"unmarshalFaster",
")",
"\n",
"if",
"ok",
"{",
"if",
"d",
".",
"fs",
"=="... | // Decode the data in the supplied data slice. | [
"Decode",
"the",
"data",
"in",
"the",
"supplied",
"data",
"slice",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/ffjson/decoder.go#L41-L57 | train |
pquerna/ffjson | ffjson/decoder.go | DecodeReader | func (d *Decoder) DecodeReader(r io.Reader, v interface{}) error {
_, ok := v.(unmarshalFaster)
_, ok2 := v.(json.Unmarshaler)
if ok || ok2 {
data, err := ioutil.ReadAll(r)
if err != nil {
return err
}
defer fflib.Pool(data)
return d.Decode(data, v)
}
dec := json.NewDecoder(r)
return dec.Decode(v)
} | go | func (d *Decoder) DecodeReader(r io.Reader, v interface{}) error {
_, ok := v.(unmarshalFaster)
_, ok2 := v.(json.Unmarshaler)
if ok || ok2 {
data, err := ioutil.ReadAll(r)
if err != nil {
return err
}
defer fflib.Pool(data)
return d.Decode(data, v)
}
dec := json.NewDecoder(r)
return dec.Decode(v)
} | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"DecodeReader",
"(",
"r",
"io",
".",
"Reader",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"_",
",",
"ok",
":=",
"v",
".",
"(",
"unmarshalFaster",
")",
"\n",
"_",
",",
"ok2",
":=",
"v",
".",
"(",
... | // Decode the data from the supplied reader.
// You should expect that data is read into memory before it is decoded. | [
"Decode",
"the",
"data",
"from",
"the",
"supplied",
"reader",
".",
"You",
"should",
"expect",
"that",
"data",
"is",
"read",
"into",
"memory",
"before",
"it",
"is",
"decoded",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/ffjson/decoder.go#L61-L74 | train |
pquerna/ffjson | fflib/v1/internal/atof.go | readFloat | func readFloat(s []byte) (mantissa uint64, exp int, neg, trunc, ok bool) {
const uint64digits = 19
i := 0
// optional sign
if i >= len(s) {
return
}
switch {
case s[i] == '+':
i++
case s[i] == '-':
neg = true
i++
}
// digits
sawdot := false
sawdigits := false
nd := 0
ndMant := 0
dp := 0
for ; i < len(s); i++ {
switch c := s[i]; true {
case c == '.':
if sawdot {
return
}
sawdot = true
dp = nd
continue
case '0' <= c && c <= '9':
sawdigits = true
if c == '0' && nd == 0 { // ignore leading zeros
dp--
continue
}
nd++
if ndMant < uint64digits {
mantissa *= 10
mantissa += uint64(c - '0')
ndMant++
} else if s[i] != '0' {
trunc = true
}
continue
}
break
}
if !sawdigits {
return
}
if !sawdot {
dp = nd
}
// optional exponent moves decimal point.
// if we read a very large, very long number,
// just be sure to move the decimal point by
// a lot (say, 100000). it doesn't matter if it's
// not the exact number.
if i < len(s) && (s[i] == 'e' || s[i] == 'E') {
i++
if i >= len(s) {
return
}
esign := 1
if s[i] == '+' {
i++
} else if s[i] == '-' {
i++
esign = -1
}
if i >= len(s) || s[i] < '0' || s[i] > '9' {
return
}
e := 0
for ; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ {
if e < 10000 {
e = e*10 + int(s[i]) - '0'
}
}
dp += e * esign
}
if i != len(s) {
return
}
exp = dp - ndMant
ok = true
return
} | go | func readFloat(s []byte) (mantissa uint64, exp int, neg, trunc, ok bool) {
const uint64digits = 19
i := 0
// optional sign
if i >= len(s) {
return
}
switch {
case s[i] == '+':
i++
case s[i] == '-':
neg = true
i++
}
// digits
sawdot := false
sawdigits := false
nd := 0
ndMant := 0
dp := 0
for ; i < len(s); i++ {
switch c := s[i]; true {
case c == '.':
if sawdot {
return
}
sawdot = true
dp = nd
continue
case '0' <= c && c <= '9':
sawdigits = true
if c == '0' && nd == 0 { // ignore leading zeros
dp--
continue
}
nd++
if ndMant < uint64digits {
mantissa *= 10
mantissa += uint64(c - '0')
ndMant++
} else if s[i] != '0' {
trunc = true
}
continue
}
break
}
if !sawdigits {
return
}
if !sawdot {
dp = nd
}
// optional exponent moves decimal point.
// if we read a very large, very long number,
// just be sure to move the decimal point by
// a lot (say, 100000). it doesn't matter if it's
// not the exact number.
if i < len(s) && (s[i] == 'e' || s[i] == 'E') {
i++
if i >= len(s) {
return
}
esign := 1
if s[i] == '+' {
i++
} else if s[i] == '-' {
i++
esign = -1
}
if i >= len(s) || s[i] < '0' || s[i] > '9' {
return
}
e := 0
for ; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ {
if e < 10000 {
e = e*10 + int(s[i]) - '0'
}
}
dp += e * esign
}
if i != len(s) {
return
}
exp = dp - ndMant
ok = true
return
} | [
"func",
"readFloat",
"(",
"s",
"[",
"]",
"byte",
")",
"(",
"mantissa",
"uint64",
",",
"exp",
"int",
",",
"neg",
",",
"trunc",
",",
"ok",
"bool",
")",
"{",
"const",
"uint64digits",
"=",
"19",
"\n",
"i",
":=",
"0",
"\n\n",
"// optional sign",
"if",
"... | // readFloat reads a decimal mantissa and exponent from a float
// string representation. It sets ok to false if the number could
// not fit return types or is invalid. | [
"readFloat",
"reads",
"a",
"decimal",
"mantissa",
"and",
"exponent",
"from",
"a",
"float",
"string",
"representation",
".",
"It",
"sets",
"ok",
"to",
"false",
"if",
"the",
"number",
"could",
"not",
"fit",
"return",
"types",
"or",
"is",
"invalid",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/fflib/v1/internal/atof.go#L176-L270 | train |
pquerna/ffjson | fflib/v1/internal/ftoa.go | appendFloat | func appendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte {
return genericFtoa(dst, f, fmt, prec, bitSize)
} | go | func appendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte {
return genericFtoa(dst, f, fmt, prec, bitSize)
} | [
"func",
"appendFloat",
"(",
"dst",
"[",
"]",
"byte",
",",
"f",
"float64",
",",
"fmt",
"byte",
",",
"prec",
"int",
",",
"bitSize",
"int",
")",
"[",
"]",
"byte",
"{",
"return",
"genericFtoa",
"(",
"dst",
",",
"f",
",",
"fmt",
",",
"prec",
",",
"bit... | // AppendFloat appends the string form of the floating-point number f,
// as generated by FormatFloat, to dst and returns the extended buffer. | [
"AppendFloat",
"appends",
"the",
"string",
"form",
"of",
"the",
"floating",
"-",
"point",
"number",
"f",
"as",
"generated",
"by",
"FormatFloat",
"to",
"dst",
"and",
"returns",
"the",
"extended",
"buffer",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/fflib/v1/internal/ftoa.go#L50-L52 | train |
pquerna/ffjson | ffjson/encoder.go | NewEncoder | func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w: w, enc: json.NewEncoder(w)}
} | go | func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w: w, enc: json.NewEncoder(w)}
} | [
"func",
"NewEncoder",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Encoder",
"{",
"return",
"&",
"Encoder",
"{",
"w",
":",
"w",
",",
"enc",
":",
"json",
".",
"NewEncoder",
"(",
"w",
")",
"}",
"\n",
"}"
] | // NewEncoder returns a reusable Encoder.
// Output will be written to the supplied writer. | [
"NewEncoder",
"returns",
"a",
"reusable",
"Encoder",
".",
"Output",
"will",
"be",
"written",
"to",
"the",
"supplied",
"writer",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/ffjson/encoder.go#L50-L52 | train |
pquerna/ffjson | ffjson/encoder.go | Encode | func (e *Encoder) Encode(v interface{}) error {
f, ok := v.(marshalerFaster)
if ok {
e.buf.Reset()
err := f.MarshalJSONBuf(&e.buf)
if err != nil {
return err
}
_, err = io.Copy(e.w, &e.buf)
return err
}
return e.enc.Encode(v)
} | go | func (e *Encoder) Encode(v interface{}) error {
f, ok := v.(marshalerFaster)
if ok {
e.buf.Reset()
err := f.MarshalJSONBuf(&e.buf)
if err != nil {
return err
}
_, err = io.Copy(e.w, &e.buf)
return err
}
return e.enc.Encode(v)
} | [
"func",
"(",
"e",
"*",
"Encoder",
")",
"Encode",
"(",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"f",
",",
"ok",
":=",
"v",
".",
"(",
"marshalerFaster",
")",
"\n",
"if",
"ok",
"{",
"e",
".",
"buf",
".",
"Reset",
"(",
")",
"\n",
"err",
":=... | // Encode the data in the supplied value to the stream
// given on creation.
// When the function returns the output has been
// written to the stream. | [
"Encode",
"the",
"data",
"in",
"the",
"supplied",
"value",
"to",
"the",
"stream",
"given",
"on",
"creation",
".",
"When",
"the",
"function",
"returns",
"the",
"output",
"has",
"been",
"written",
"to",
"the",
"stream",
"."
] | e517b90714f7c0eabe6d2e570a5886ae077d6db6 | https://github.com/pquerna/ffjson/blob/e517b90714f7c0eabe6d2e570a5886ae077d6db6/ffjson/encoder.go#L58-L72 | train |
araddon/dateparse | parseany.go | MustParse | func MustParse(datestr string) time.Time {
p, err := parseTime(datestr, nil)
if err != nil {
panic(err.Error())
}
t, err := p.parse()
if err != nil {
panic(err.Error())
}
return t
} | go | func MustParse(datestr string) time.Time {
p, err := parseTime(datestr, nil)
if err != nil {
panic(err.Error())
}
t, err := p.parse()
if err != nil {
panic(err.Error())
}
return t
} | [
"func",
"MustParse",
"(",
"datestr",
"string",
")",
"time",
".",
"Time",
"{",
"p",
",",
"err",
":=",
"parseTime",
"(",
"datestr",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"}",
... | // MustParse parse a date, and panic if it can't be parsed. Used for testing.
// Not recommended for most use-cases. | [
"MustParse",
"parse",
"a",
"date",
"and",
"panic",
"if",
"it",
"can",
"t",
"be",
"parsed",
".",
"Used",
"for",
"testing",
".",
"Not",
"recommended",
"for",
"most",
"use",
"-",
"cases",
"."
] | 0d74ffceef83c568c4c47a6e74de8ee5c5955048 | https://github.com/araddon/dateparse/blob/0d74ffceef83c568c4c47a6e74de8ee5c5955048/parseany.go#L169-L179 | train |
ulule/limiter | limiter.go | New | func New(store Store, rate Rate, options ...Option) *Limiter {
opt := Options{
IPv4Mask: DefaultIPv4Mask,
IPv6Mask: DefaultIPv6Mask,
TrustForwardHeader: false,
}
for _, o := range options {
o(&opt)
}
return &Limiter{
Store: store,
Rate: rate,
Options: opt,
}
} | go | func New(store Store, rate Rate, options ...Option) *Limiter {
opt := Options{
IPv4Mask: DefaultIPv4Mask,
IPv6Mask: DefaultIPv6Mask,
TrustForwardHeader: false,
}
for _, o := range options {
o(&opt)
}
return &Limiter{
Store: store,
Rate: rate,
Options: opt,
}
} | [
"func",
"New",
"(",
"store",
"Store",
",",
"rate",
"Rate",
",",
"options",
"...",
"Option",
")",
"*",
"Limiter",
"{",
"opt",
":=",
"Options",
"{",
"IPv4Mask",
":",
"DefaultIPv4Mask",
",",
"IPv6Mask",
":",
"DefaultIPv6Mask",
",",
"TrustForwardHeader",
":",
... | // New returns an instance of Limiter. | [
"New",
"returns",
"an",
"instance",
"of",
"Limiter",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/limiter.go#L31-L45 | train |
ulule/limiter | limiter.go | Peek | func (limiter *Limiter) Peek(ctx context.Context, key string) (Context, error) {
return limiter.Store.Peek(ctx, key, limiter.Rate)
} | go | func (limiter *Limiter) Peek(ctx context.Context, key string) (Context, error) {
return limiter.Store.Peek(ctx, key, limiter.Rate)
} | [
"func",
"(",
"limiter",
"*",
"Limiter",
")",
"Peek",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"(",
"Context",
",",
"error",
")",
"{",
"return",
"limiter",
".",
"Store",
".",
"Peek",
"(",
"ctx",
",",
"key",
",",
"limiter",
"... | // Peek returns the limit for given identifier, without modification on current values. | [
"Peek",
"returns",
"the",
"limit",
"for",
"given",
"identifier",
"without",
"modification",
"on",
"current",
"values",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/limiter.go#L53-L55 | train |
ulule/limiter | drivers/middleware/stdlib/middleware.go | Handler | func (middleware *Middleware) Handler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
context, err := middleware.Limiter.Get(r.Context(), middleware.Limiter.GetIPKey(r))
if err != nil {
middleware.OnError(w, r, err)
return
}
w.Header().Add("X-RateLimit-Limit", strconv.FormatInt(context.Limit, 10))
w.Header().Add("X-RateLimit-Remaining", strconv.FormatInt(context.Remaining, 10))
w.Header().Add("X-RateLimit-Reset", strconv.FormatInt(context.Reset, 10))
if context.Reached {
middleware.OnLimitReached(w, r)
return
}
h.ServeHTTP(w, r)
})
} | go | func (middleware *Middleware) Handler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
context, err := middleware.Limiter.Get(r.Context(), middleware.Limiter.GetIPKey(r))
if err != nil {
middleware.OnError(w, r, err)
return
}
w.Header().Add("X-RateLimit-Limit", strconv.FormatInt(context.Limit, 10))
w.Header().Add("X-RateLimit-Remaining", strconv.FormatInt(context.Remaining, 10))
w.Header().Add("X-RateLimit-Reset", strconv.FormatInt(context.Reset, 10))
if context.Reached {
middleware.OnLimitReached(w, r)
return
}
h.ServeHTTP(w, r)
})
} | [
"func",
"(",
"middleware",
"*",
"Middleware",
")",
"Handler",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
... | // Handler the middleware handler. | [
"Handler",
"the",
"middleware",
"handler",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/stdlib/middleware.go#L34-L53 | train |
ulule/limiter | drivers/store/common/context.go | GetContextFromState | func GetContextFromState(now time.Time, rate limiter.Rate, expiration time.Time, count int64) limiter.Context {
limit := rate.Limit
remaining := int64(0)
reached := true
if count <= limit {
remaining = limit - count
reached = false
}
reset := expiration.Unix()
return limiter.Context{
Limit: limit,
Remaining: remaining,
Reset: reset,
Reached: reached,
}
} | go | func GetContextFromState(now time.Time, rate limiter.Rate, expiration time.Time, count int64) limiter.Context {
limit := rate.Limit
remaining := int64(0)
reached := true
if count <= limit {
remaining = limit - count
reached = false
}
reset := expiration.Unix()
return limiter.Context{
Limit: limit,
Remaining: remaining,
Reset: reset,
Reached: reached,
}
} | [
"func",
"GetContextFromState",
"(",
"now",
"time",
".",
"Time",
",",
"rate",
"limiter",
".",
"Rate",
",",
"expiration",
"time",
".",
"Time",
",",
"count",
"int64",
")",
"limiter",
".",
"Context",
"{",
"limit",
":=",
"rate",
".",
"Limit",
"\n",
"remaining... | // GetContextFromState generate a new limiter.Context from given state. | [
"GetContextFromState",
"generate",
"a",
"new",
"limiter",
".",
"Context",
"from",
"given",
"state",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/common/context.go#L10-L28 | train |
ulule/limiter | drivers/store/memory/cache.go | Run | func (cleaner *cleaner) Run(cache *Cache) {
ticker := time.NewTicker(cleaner.interval)
for {
select {
case <-ticker.C:
cache.Clean()
case <-cleaner.stop:
ticker.Stop()
return
}
}
} | go | func (cleaner *cleaner) Run(cache *Cache) {
ticker := time.NewTicker(cleaner.interval)
for {
select {
case <-ticker.C:
cache.Clean()
case <-cleaner.stop:
ticker.Stop()
return
}
}
} | [
"func",
"(",
"cleaner",
"*",
"cleaner",
")",
"Run",
"(",
"cache",
"*",
"Cache",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"cleaner",
".",
"interval",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-",
"ticker",
".",
"C",
":",
"cache... | // Run will periodically delete expired keys from given cache until GC notify that it should stop. | [
"Run",
"will",
"periodically",
"delete",
"expired",
"keys",
"from",
"given",
"cache",
"until",
"GC",
"notify",
"that",
"it",
"should",
"stop",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L24-L35 | train |
ulule/limiter | drivers/store/memory/cache.go | startCleaner | func startCleaner(cache *Cache, interval time.Duration) {
cleaner := &cleaner{
interval: interval,
stop: make(chan bool),
}
cache.cleaner = cleaner
go cleaner.Run(cache)
} | go | func startCleaner(cache *Cache, interval time.Duration) {
cleaner := &cleaner{
interval: interval,
stop: make(chan bool),
}
cache.cleaner = cleaner
go cleaner.Run(cache)
} | [
"func",
"startCleaner",
"(",
"cache",
"*",
"Cache",
",",
"interval",
"time",
".",
"Duration",
")",
"{",
"cleaner",
":=",
"&",
"cleaner",
"{",
"interval",
":",
"interval",
",",
"stop",
":",
"make",
"(",
"chan",
"bool",
")",
",",
"}",
"\n\n",
"cache",
... | // startCleaner will start a cleaner goroutine for given cache. | [
"startCleaner",
"will",
"start",
"a",
"cleaner",
"goroutine",
"for",
"given",
"cache",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L43-L51 | train |
ulule/limiter | drivers/store/memory/cache.go | Expired | func (counter Counter) Expired() bool {
if counter.Expiration == 0 {
return false
}
return time.Now().UnixNano() > counter.Expiration
} | go | func (counter Counter) Expired() bool {
if counter.Expiration == 0 {
return false
}
return time.Now().UnixNano() > counter.Expiration
} | [
"func",
"(",
"counter",
"Counter",
")",
"Expired",
"(",
")",
"bool",
"{",
"if",
"counter",
".",
"Expiration",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
">",
"counter",
"."... | // Expired returns true if the counter has expired. | [
"Expired",
"returns",
"true",
"if",
"the",
"counter",
"has",
"expired",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L60-L65 | train |
ulule/limiter | drivers/store/memory/cache.go | NewCache | func NewCache(cleanInterval time.Duration) *CacheWrapper {
cache := &Cache{
counters: map[string]Counter{},
}
wrapper := &CacheWrapper{Cache: cache}
if cleanInterval > 0 {
startCleaner(cache, cleanInterval)
runtime.SetFinalizer(wrapper, stopCleaner)
}
return wrapper
} | go | func NewCache(cleanInterval time.Duration) *CacheWrapper {
cache := &Cache{
counters: map[string]Counter{},
}
wrapper := &CacheWrapper{Cache: cache}
if cleanInterval > 0 {
startCleaner(cache, cleanInterval)
runtime.SetFinalizer(wrapper, stopCleaner)
}
return wrapper
} | [
"func",
"NewCache",
"(",
"cleanInterval",
"time",
".",
"Duration",
")",
"*",
"CacheWrapper",
"{",
"cache",
":=",
"&",
"Cache",
"{",
"counters",
":",
"map",
"[",
"string",
"]",
"Counter",
"{",
"}",
",",
"}",
"\n\n",
"wrapper",
":=",
"&",
"CacheWrapper",
... | // NewCache returns a new cache. | [
"NewCache",
"returns",
"a",
"new",
"cache",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L75-L89 | train |
ulule/limiter | drivers/store/memory/cache.go | Increment | func (cache *Cache) Increment(key string, value int64, duration time.Duration) (int64, time.Time) {
cache.mutex.Lock()
counter, ok := cache.counters[key]
if !ok || counter.Expired() {
expiration := time.Now().Add(duration).UnixNano()
counter = Counter{
Value: value,
Expiration: expiration,
}
cache.counters[key] = counter
cache.mutex.Unlock()
return value, time.Unix(0, expiration)
}
value = counter.Value + value
counter.Value = value
expiration := counter.Expiration
cache.counters[key] = counter
cache.mutex.Unlock()
return value, time.Unix(0, expiration)
} | go | func (cache *Cache) Increment(key string, value int64, duration time.Duration) (int64, time.Time) {
cache.mutex.Lock()
counter, ok := cache.counters[key]
if !ok || counter.Expired() {
expiration := time.Now().Add(duration).UnixNano()
counter = Counter{
Value: value,
Expiration: expiration,
}
cache.counters[key] = counter
cache.mutex.Unlock()
return value, time.Unix(0, expiration)
}
value = counter.Value + value
counter.Value = value
expiration := counter.Expiration
cache.counters[key] = counter
cache.mutex.Unlock()
return value, time.Unix(0, expiration)
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Increment",
"(",
"key",
"string",
",",
"value",
"int64",
",",
"duration",
"time",
".",
"Duration",
")",
"(",
"int64",
",",
"time",
".",
"Time",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n\n"... | // Increment increments given value on key.
// If key is undefined or expired, it will create it. | [
"Increment",
"increments",
"given",
"value",
"on",
"key",
".",
"If",
"key",
"is",
"undefined",
"or",
"expired",
"it",
"will",
"create",
"it",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L93-L118 | train |
ulule/limiter | drivers/store/memory/cache.go | Get | func (cache *Cache) Get(key string, duration time.Duration) (int64, time.Time) {
cache.mutex.RLock()
counter, ok := cache.counters[key]
if !ok || counter.Expired() {
expiration := time.Now().Add(duration).UnixNano()
cache.mutex.RUnlock()
return 0, time.Unix(0, expiration)
}
value := counter.Value
expiration := counter.Expiration
cache.mutex.RUnlock()
return value, time.Unix(0, expiration)
} | go | func (cache *Cache) Get(key string, duration time.Duration) (int64, time.Time) {
cache.mutex.RLock()
counter, ok := cache.counters[key]
if !ok || counter.Expired() {
expiration := time.Now().Add(duration).UnixNano()
cache.mutex.RUnlock()
return 0, time.Unix(0, expiration)
}
value := counter.Value
expiration := counter.Expiration
cache.mutex.RUnlock()
return value, time.Unix(0, expiration)
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Get",
"(",
"key",
"string",
",",
"duration",
"time",
".",
"Duration",
")",
"(",
"int64",
",",
"time",
".",
"Time",
")",
"{",
"cache",
".",
"mutex",
".",
"RLock",
"(",
")",
"\n\n",
"counter",
",",
"ok",
":... | // Get returns key's value and expiration. | [
"Get",
"returns",
"key",
"s",
"value",
"and",
"expiration",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L121-L136 | train |
ulule/limiter | drivers/store/memory/cache.go | Clean | func (cache *Cache) Clean() {
now := time.Now().UnixNano()
cache.mutex.Lock()
for key, counter := range cache.counters {
if now > counter.Expiration {
delete(cache.counters, key)
}
}
cache.mutex.Unlock()
} | go | func (cache *Cache) Clean() {
now := time.Now().UnixNano()
cache.mutex.Lock()
for key, counter := range cache.counters {
if now > counter.Expiration {
delete(cache.counters, key)
}
}
cache.mutex.Unlock()
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Clean",
"(",
")",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
"\n\n",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"for",
"key",
",",
"counter",
":=",
"range",
"cac... | // Clean will deleted any expired keys. | [
"Clean",
"will",
"deleted",
"any",
"expired",
"keys",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/cache.go#L139-L149 | train |
ulule/limiter | drivers/middleware/gin/middleware.go | Handle | func (middleware *Middleware) Handle(c *gin.Context) {
key := middleware.KeyGetter(c)
context, err := middleware.Limiter.Get(c, key)
if err != nil {
middleware.OnError(c, err)
c.Abort()
return
}
c.Header("X-RateLimit-Limit", strconv.FormatInt(context.Limit, 10))
c.Header("X-RateLimit-Remaining", strconv.FormatInt(context.Remaining, 10))
c.Header("X-RateLimit-Reset", strconv.FormatInt(context.Reset, 10))
if context.Reached {
middleware.OnLimitReached(c)
c.Abort()
return
}
c.Next()
} | go | func (middleware *Middleware) Handle(c *gin.Context) {
key := middleware.KeyGetter(c)
context, err := middleware.Limiter.Get(c, key)
if err != nil {
middleware.OnError(c, err)
c.Abort()
return
}
c.Header("X-RateLimit-Limit", strconv.FormatInt(context.Limit, 10))
c.Header("X-RateLimit-Remaining", strconv.FormatInt(context.Remaining, 10))
c.Header("X-RateLimit-Reset", strconv.FormatInt(context.Reset, 10))
if context.Reached {
middleware.OnLimitReached(c)
c.Abort()
return
}
c.Next()
} | [
"func",
"(",
"middleware",
"*",
"Middleware",
")",
"Handle",
"(",
"c",
"*",
"gin",
".",
"Context",
")",
"{",
"key",
":=",
"middleware",
".",
"KeyGetter",
"(",
"c",
")",
"\n",
"context",
",",
"err",
":=",
"middleware",
".",
"Limiter",
".",
"Get",
"(",... | // Handle gin request. | [
"Handle",
"gin",
"request",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/gin/middleware.go#L38-L58 | train |
ulule/limiter | drivers/middleware/gin/options.go | WithErrorHandler | func WithErrorHandler(handler ErrorHandler) Option {
return option(func(middleware *Middleware) {
middleware.OnError = handler
})
} | go | func WithErrorHandler(handler ErrorHandler) Option {
return option(func(middleware *Middleware) {
middleware.OnError = handler
})
} | [
"func",
"WithErrorHandler",
"(",
"handler",
"ErrorHandler",
")",
"Option",
"{",
"return",
"option",
"(",
"func",
"(",
"middleware",
"*",
"Middleware",
")",
"{",
"middleware",
".",
"OnError",
"=",
"handler",
"\n",
"}",
")",
"\n",
"}"
] | // WithErrorHandler will configure the Middleware to use the given ErrorHandler. | [
"WithErrorHandler",
"will",
"configure",
"the",
"Middleware",
"to",
"use",
"the",
"given",
"ErrorHandler",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/gin/options.go#L24-L28 | train |
ulule/limiter | drivers/middleware/gin/options.go | WithLimitReachedHandler | func WithLimitReachedHandler(handler LimitReachedHandler) Option {
return option(func(middleware *Middleware) {
middleware.OnLimitReached = handler
})
} | go | func WithLimitReachedHandler(handler LimitReachedHandler) Option {
return option(func(middleware *Middleware) {
middleware.OnLimitReached = handler
})
} | [
"func",
"WithLimitReachedHandler",
"(",
"handler",
"LimitReachedHandler",
")",
"Option",
"{",
"return",
"option",
"(",
"func",
"(",
"middleware",
"*",
"Middleware",
")",
"{",
"middleware",
".",
"OnLimitReached",
"=",
"handler",
"\n",
"}",
")",
"\n",
"}"
] | // WithLimitReachedHandler will configure the Middleware to use the given LimitReachedHandler. | [
"WithLimitReachedHandler",
"will",
"configure",
"the",
"Middleware",
"to",
"use",
"the",
"given",
"LimitReachedHandler",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/gin/options.go#L39-L43 | train |
ulule/limiter | drivers/middleware/gin/options.go | WithKeyGetter | func WithKeyGetter(KeyGetter KeyGetter) Option {
return option(func(middleware *Middleware) {
middleware.KeyGetter = KeyGetter
})
} | go | func WithKeyGetter(KeyGetter KeyGetter) Option {
return option(func(middleware *Middleware) {
middleware.KeyGetter = KeyGetter
})
} | [
"func",
"WithKeyGetter",
"(",
"KeyGetter",
"KeyGetter",
")",
"Option",
"{",
"return",
"option",
"(",
"func",
"(",
"middleware",
"*",
"Middleware",
")",
"{",
"middleware",
".",
"KeyGetter",
"=",
"KeyGetter",
"\n",
"}",
")",
"\n",
"}"
] | // WithKeyGetter will configure the Middleware to use the given KeyGetter | [
"WithKeyGetter",
"will",
"configure",
"the",
"Middleware",
"to",
"use",
"the",
"given",
"KeyGetter"
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/gin/options.go#L54-L58 | train |
ulule/limiter | rate.go | NewRateFromFormatted | func NewRateFromFormatted(formatted string) (Rate, error) {
rate := Rate{}
values := strings.Split(formatted, "-")
if len(values) != 2 {
return rate, errors.Errorf("incorrect format '%s'", formatted)
}
periods := map[string]time.Duration{
"S": time.Second, // Second
"M": time.Minute, // Minute
"H": time.Hour, // Hour
}
limit, period := values[0], strings.ToUpper(values[1])
duration, ok := periods[period]
if !ok {
return rate, errors.Errorf("incorrect period '%s'", period)
}
p := 1 * duration
l, err := strconv.ParseInt(limit, 10, 64)
if err != nil {
return rate, errors.Errorf("incorrect limit '%s'", limit)
}
rate = Rate{
Formatted: formatted,
Period: p,
Limit: l,
}
return rate, nil
} | go | func NewRateFromFormatted(formatted string) (Rate, error) {
rate := Rate{}
values := strings.Split(formatted, "-")
if len(values) != 2 {
return rate, errors.Errorf("incorrect format '%s'", formatted)
}
periods := map[string]time.Duration{
"S": time.Second, // Second
"M": time.Minute, // Minute
"H": time.Hour, // Hour
}
limit, period := values[0], strings.ToUpper(values[1])
duration, ok := periods[period]
if !ok {
return rate, errors.Errorf("incorrect period '%s'", period)
}
p := 1 * duration
l, err := strconv.ParseInt(limit, 10, 64)
if err != nil {
return rate, errors.Errorf("incorrect limit '%s'", limit)
}
rate = Rate{
Formatted: formatted,
Period: p,
Limit: l,
}
return rate, nil
} | [
"func",
"NewRateFromFormatted",
"(",
"formatted",
"string",
")",
"(",
"Rate",
",",
"error",
")",
"{",
"rate",
":=",
"Rate",
"{",
"}",
"\n\n",
"values",
":=",
"strings",
".",
"Split",
"(",
"formatted",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"va... | // NewRateFromFormatted returns the rate from the formatted version. | [
"NewRateFromFormatted",
"returns",
"the",
"rate",
"from",
"the",
"formatted",
"version",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/rate.go#L19-L53 | train |
ulule/limiter | options.go | WithIPv4Mask | func WithIPv4Mask(mask net.IPMask) Option {
return func(o *Options) {
o.IPv4Mask = mask
}
} | go | func WithIPv4Mask(mask net.IPMask) Option {
return func(o *Options) {
o.IPv4Mask = mask
}
} | [
"func",
"WithIPv4Mask",
"(",
"mask",
"net",
".",
"IPMask",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"IPv4Mask",
"=",
"mask",
"\n",
"}",
"\n",
"}"
] | // WithIPv4Mask will configure the limiter to use given mask for IPv4 address. | [
"WithIPv4Mask",
"will",
"configure",
"the",
"limiter",
"to",
"use",
"given",
"mask",
"for",
"IPv4",
"address",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/options.go#L21-L25 | train |
ulule/limiter | options.go | WithIPv6Mask | func WithIPv6Mask(mask net.IPMask) Option {
return func(o *Options) {
o.IPv6Mask = mask
}
} | go | func WithIPv6Mask(mask net.IPMask) Option {
return func(o *Options) {
o.IPv6Mask = mask
}
} | [
"func",
"WithIPv6Mask",
"(",
"mask",
"net",
".",
"IPMask",
")",
"Option",
"{",
"return",
"func",
"(",
"o",
"*",
"Options",
")",
"{",
"o",
".",
"IPv6Mask",
"=",
"mask",
"\n",
"}",
"\n",
"}"
] | // WithIPv6Mask will configure the limiter to use given mask for IPv6 address. | [
"WithIPv6Mask",
"will",
"configure",
"the",
"limiter",
"to",
"use",
"given",
"mask",
"for",
"IPv6",
"address",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/options.go#L28-L32 | train |
ulule/limiter | drivers/middleware/stdlib/options.go | DefaultErrorHandler | func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
panic(err)
} | go | func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
panic(err)
} | [
"func",
"DefaultErrorHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"panic",
"(",
"err",
")",
"\n",
"}"
] | // DefaultErrorHandler is the default ErrorHandler used by a new Middleware. | [
"DefaultErrorHandler",
"is",
"the",
"default",
"ErrorHandler",
"used",
"by",
"a",
"new",
"Middleware",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/stdlib/options.go#L29-L31 | train |
ulule/limiter | drivers/middleware/stdlib/options.go | DefaultLimitReachedHandler | func DefaultLimitReachedHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Limit exceeded", http.StatusTooManyRequests)
} | go | func DefaultLimitReachedHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Limit exceeded", http.StatusTooManyRequests)
} | [
"func",
"DefaultLimitReachedHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"http",
".",
"Error",
"(",
"w",
",",
"\"",
"\"",
",",
"http",
".",
"StatusTooManyRequests",
")",
"\n",
"}"
] | // DefaultLimitReachedHandler is the default LimitReachedHandler used by a new Middleware. | [
"DefaultLimitReachedHandler",
"is",
"the",
"default",
"LimitReachedHandler",
"used",
"by",
"a",
"new",
"Middleware",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/middleware/stdlib/options.go#L44-L46 | train |
ulule/limiter | drivers/store/redis/store.go | NewStore | func NewStore(client Client) (limiter.Store, error) {
return NewStoreWithOptions(client, limiter.StoreOptions{
Prefix: limiter.DefaultPrefix,
CleanUpInterval: limiter.DefaultCleanUpInterval,
MaxRetry: limiter.DefaultMaxRetry,
})
} | go | func NewStore(client Client) (limiter.Store, error) {
return NewStoreWithOptions(client, limiter.StoreOptions{
Prefix: limiter.DefaultPrefix,
CleanUpInterval: limiter.DefaultCleanUpInterval,
MaxRetry: limiter.DefaultMaxRetry,
})
} | [
"func",
"NewStore",
"(",
"client",
"Client",
")",
"(",
"limiter",
".",
"Store",
",",
"error",
")",
"{",
"return",
"NewStoreWithOptions",
"(",
"client",
",",
"limiter",
".",
"StoreOptions",
"{",
"Prefix",
":",
"limiter",
".",
"DefaultPrefix",
",",
"CleanUpInt... | // NewStore returns an instance of redis store with defaults. | [
"NewStore",
"returns",
"an",
"instance",
"of",
"redis",
"store",
"with",
"defaults",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L37-L43 | train |
ulule/limiter | drivers/store/redis/store.go | NewStoreWithOptions | func NewStoreWithOptions(client Client, options limiter.StoreOptions) (limiter.Store, error) {
store := &Store{
client: client,
Prefix: options.Prefix,
MaxRetry: options.MaxRetry,
}
if store.MaxRetry <= 0 {
store.MaxRetry = 1
}
_, err := store.ping()
if err != nil {
return nil, err
}
return store, nil
} | go | func NewStoreWithOptions(client Client, options limiter.StoreOptions) (limiter.Store, error) {
store := &Store{
client: client,
Prefix: options.Prefix,
MaxRetry: options.MaxRetry,
}
if store.MaxRetry <= 0 {
store.MaxRetry = 1
}
_, err := store.ping()
if err != nil {
return nil, err
}
return store, nil
} | [
"func",
"NewStoreWithOptions",
"(",
"client",
"Client",
",",
"options",
"limiter",
".",
"StoreOptions",
")",
"(",
"limiter",
".",
"Store",
",",
"error",
")",
"{",
"store",
":=",
"&",
"Store",
"{",
"client",
":",
"client",
",",
"Prefix",
":",
"options",
"... | // NewStoreWithOptions returns an instance of redis store with options. | [
"NewStoreWithOptions",
"returns",
"an",
"instance",
"of",
"redis",
"store",
"with",
"options",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L46-L63 | train |
ulule/limiter | drivers/store/redis/store.go | peekValue | func peekValue(rtx *libredis.Tx, key string) (int64, time.Duration, error) {
pipe := rtx.Pipeline()
value := pipe.Get(key)
expire := pipe.PTTL(key)
_, err := pipe.Exec()
if err != nil && err != libredis.Nil {
return 0, 0, err
}
count, err := value.Int64()
if err != nil && err != libredis.Nil {
return 0, 0, err
}
ttl, err := expire.Result()
if err != nil {
return 0, 0, err
}
return count, ttl, nil
} | go | func peekValue(rtx *libredis.Tx, key string) (int64, time.Duration, error) {
pipe := rtx.Pipeline()
value := pipe.Get(key)
expire := pipe.PTTL(key)
_, err := pipe.Exec()
if err != nil && err != libredis.Nil {
return 0, 0, err
}
count, err := value.Int64()
if err != nil && err != libredis.Nil {
return 0, 0, err
}
ttl, err := expire.Result()
if err != nil {
return 0, 0, err
}
return count, ttl, nil
} | [
"func",
"peekValue",
"(",
"rtx",
"*",
"libredis",
".",
"Tx",
",",
"key",
"string",
")",
"(",
"int64",
",",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"pipe",
":=",
"rtx",
".",
"Pipeline",
"(",
")",
"\n",
"value",
":=",
"pipe",
".",
"Get",
"... | // peekValue will retrieve the counter and its expiration for given key. | [
"peekValue",
"will",
"retrieve",
"the",
"counter",
"and",
"its",
"expiration",
"for",
"given",
"key",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L149-L170 | train |
ulule/limiter | drivers/store/redis/store.go | setValue | func setValue(rtx *libredis.Tx, key string, expiration time.Duration) (bool, error) {
value := rtx.SetNX(key, 1, expiration)
created, err := value.Result()
if err != nil {
return false, err
}
return created, nil
} | go | func setValue(rtx *libredis.Tx, key string, expiration time.Duration) (bool, error) {
value := rtx.SetNX(key, 1, expiration)
created, err := value.Result()
if err != nil {
return false, err
}
return created, nil
} | [
"func",
"setValue",
"(",
"rtx",
"*",
"libredis",
".",
"Tx",
",",
"key",
"string",
",",
"expiration",
"time",
".",
"Duration",
")",
"(",
"bool",
",",
"error",
")",
"{",
"value",
":=",
"rtx",
".",
"SetNX",
"(",
"key",
",",
"1",
",",
"expiration",
")"... | // setValue will try to initialize a new counter if given key doesn't exists. | [
"setValue",
"will",
"try",
"to",
"initialize",
"a",
"new",
"counter",
"if",
"given",
"key",
"doesn",
"t",
"exists",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L184-L193 | train |
ulule/limiter | drivers/store/redis/store.go | updateValue | func updateValue(rtx *libredis.Tx, key string, expiration time.Duration) (int64, time.Duration, error) {
pipe := rtx.Pipeline()
value := pipe.Incr(key)
expire := pipe.PTTL(key)
_, err := pipe.Exec()
if err != nil {
return 0, 0, err
}
count, err := value.Result()
if err != nil {
return 0, 0, err
}
ttl, err := expire.Result()
if err != nil {
return 0, 0, err
}
// If ttl is -1ms, we have to define key expiration.
// PTTL return values changed as of Redis 2.8
// Now the command returns -2ms if the key does not exist, and -1ms if the key exists, but there is no expiry set
// We shouldn't try to set an expiry on a key that doesn't exist
if ttl == (-1 * time.Millisecond) {
expire := rtx.Expire(key, expiration)
ok, err := expire.Result()
if err != nil {
return count, ttl, err
}
if !ok {
return count, ttl, errors.New("cannot configure timeout on key")
}
}
return count, ttl, nil
} | go | func updateValue(rtx *libredis.Tx, key string, expiration time.Duration) (int64, time.Duration, error) {
pipe := rtx.Pipeline()
value := pipe.Incr(key)
expire := pipe.PTTL(key)
_, err := pipe.Exec()
if err != nil {
return 0, 0, err
}
count, err := value.Result()
if err != nil {
return 0, 0, err
}
ttl, err := expire.Result()
if err != nil {
return 0, 0, err
}
// If ttl is -1ms, we have to define key expiration.
// PTTL return values changed as of Redis 2.8
// Now the command returns -2ms if the key does not exist, and -1ms if the key exists, but there is no expiry set
// We shouldn't try to set an expiry on a key that doesn't exist
if ttl == (-1 * time.Millisecond) {
expire := rtx.Expire(key, expiration)
ok, err := expire.Result()
if err != nil {
return count, ttl, err
}
if !ok {
return count, ttl, errors.New("cannot configure timeout on key")
}
}
return count, ttl, nil
} | [
"func",
"updateValue",
"(",
"rtx",
"*",
"libredis",
".",
"Tx",
",",
"key",
"string",
",",
"expiration",
"time",
".",
"Duration",
")",
"(",
"int64",
",",
"time",
".",
"Duration",
",",
"error",
")",
"{",
"pipe",
":=",
"rtx",
".",
"Pipeline",
"(",
")",
... | // updateValue will try to increment the counter identified by given key. | [
"updateValue",
"will",
"try",
"to",
"increment",
"the",
"counter",
"identified",
"by",
"given",
"key",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L213-L252 | train |
ulule/limiter | drivers/store/redis/store.go | ping | func (store *Store) ping() (bool, error) {
cmd := store.client.Ping()
pong, err := cmd.Result()
if err != nil {
return false, errors.Wrap(err, "limiter: cannot ping redis server")
}
return (pong == "PONG"), nil
} | go | func (store *Store) ping() (bool, error) {
cmd := store.client.Ping()
pong, err := cmd.Result()
if err != nil {
return false, errors.Wrap(err, "limiter: cannot ping redis server")
}
return (pong == "PONG"), nil
} | [
"func",
"(",
"store",
"*",
"Store",
")",
"ping",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cmd",
":=",
"store",
".",
"client",
".",
"Ping",
"(",
")",
"\n\n",
"pong",
",",
"err",
":=",
"cmd",
".",
"Result",
"(",
")",
"\n",
"if",
"err",
"... | // ping checks if redis is alive. | [
"ping",
"checks",
"if",
"redis",
"is",
"alive",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/redis/store.go#L255-L264 | train |
ulule/limiter | drivers/store/memory/store.go | NewStore | func NewStore() limiter.Store {
return NewStoreWithOptions(limiter.StoreOptions{
Prefix: limiter.DefaultPrefix,
CleanUpInterval: limiter.DefaultCleanUpInterval,
})
} | go | func NewStore() limiter.Store {
return NewStoreWithOptions(limiter.StoreOptions{
Prefix: limiter.DefaultPrefix,
CleanUpInterval: limiter.DefaultCleanUpInterval,
})
} | [
"func",
"NewStore",
"(",
")",
"limiter",
".",
"Store",
"{",
"return",
"NewStoreWithOptions",
"(",
"limiter",
".",
"StoreOptions",
"{",
"Prefix",
":",
"limiter",
".",
"DefaultPrefix",
",",
"CleanUpInterval",
":",
"limiter",
".",
"DefaultCleanUpInterval",
",",
"}"... | // NewStore creates a new instance of memory store with defaults. | [
"NewStore",
"creates",
"a",
"new",
"instance",
"of",
"memory",
"store",
"with",
"defaults",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/store.go#L21-L26 | train |
ulule/limiter | drivers/store/memory/store.go | NewStoreWithOptions | func NewStoreWithOptions(options limiter.StoreOptions) limiter.Store {
return &Store{
Prefix: options.Prefix,
cache: NewCache(options.CleanUpInterval),
}
} | go | func NewStoreWithOptions(options limiter.StoreOptions) limiter.Store {
return &Store{
Prefix: options.Prefix,
cache: NewCache(options.CleanUpInterval),
}
} | [
"func",
"NewStoreWithOptions",
"(",
"options",
"limiter",
".",
"StoreOptions",
")",
"limiter",
".",
"Store",
"{",
"return",
"&",
"Store",
"{",
"Prefix",
":",
"options",
".",
"Prefix",
",",
"cache",
":",
"NewCache",
"(",
"options",
".",
"CleanUpInterval",
")"... | // NewStoreWithOptions creates a new instance of memory store with options. | [
"NewStoreWithOptions",
"creates",
"a",
"new",
"instance",
"of",
"memory",
"store",
"with",
"options",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/drivers/store/memory/store.go#L29-L34 | train |
ulule/limiter | network.go | GetIPKey | func (limiter *Limiter) GetIPKey(r *http.Request) string {
return limiter.GetIPWithMask(r).String()
} | go | func (limiter *Limiter) GetIPKey(r *http.Request) string {
return limiter.GetIPWithMask(r).String()
} | [
"func",
"(",
"limiter",
"*",
"Limiter",
")",
"GetIPKey",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"return",
"limiter",
".",
"GetIPWithMask",
"(",
"r",
")",
".",
"String",
"(",
")",
"\n",
"}"
] | // GetIPKey extracts IP from request and returns hashed IP to use as store key. | [
"GetIPKey",
"extracts",
"IP",
"from",
"request",
"and",
"returns",
"hashed",
"IP",
"to",
"use",
"as",
"store",
"key",
"."
] | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/network.go#L27-L29 | train |
ulule/limiter | network.go | GetIP | func GetIP(r *http.Request, options ...Options) net.IP {
if len(options) >= 1 && options[0].TrustForwardHeader {
ip := r.Header.Get("X-Forwarded-For")
if ip != "" {
parts := strings.SplitN(ip, ",", 2)
part := strings.TrimSpace(parts[0])
return net.ParseIP(part)
}
ip = strings.TrimSpace(r.Header.Get("X-Real-IP"))
if ip != "" {
return net.ParseIP(ip)
}
}
remoteAddr := strings.TrimSpace(r.RemoteAddr)
host, _, err := net.SplitHostPort(remoteAddr)
if err != nil {
return net.ParseIP(remoteAddr)
}
return net.ParseIP(host)
} | go | func GetIP(r *http.Request, options ...Options) net.IP {
if len(options) >= 1 && options[0].TrustForwardHeader {
ip := r.Header.Get("X-Forwarded-For")
if ip != "" {
parts := strings.SplitN(ip, ",", 2)
part := strings.TrimSpace(parts[0])
return net.ParseIP(part)
}
ip = strings.TrimSpace(r.Header.Get("X-Real-IP"))
if ip != "" {
return net.ParseIP(ip)
}
}
remoteAddr := strings.TrimSpace(r.RemoteAddr)
host, _, err := net.SplitHostPort(remoteAddr)
if err != nil {
return net.ParseIP(remoteAddr)
}
return net.ParseIP(host)
} | [
"func",
"GetIP",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"options",
"...",
"Options",
")",
"net",
".",
"IP",
"{",
"if",
"len",
"(",
"options",
")",
">=",
"1",
"&&",
"options",
"[",
"0",
"]",
".",
"TrustForwardHeader",
"{",
"ip",
":=",
"r",
".... | // GetIP returns IP address from request.
// If options is defined and TrustForwardHeader is true, it will lookup IP in
// X-Forwarded-For and X-Real-IP headers. | [
"GetIP",
"returns",
"IP",
"address",
"from",
"request",
".",
"If",
"options",
"is",
"defined",
"and",
"TrustForwardHeader",
"is",
"true",
"it",
"will",
"lookup",
"IP",
"in",
"X",
"-",
"Forwarded",
"-",
"For",
"and",
"X",
"-",
"Real",
"-",
"IP",
"headers"... | d1a9972e76c234debd9f4cf39c847ea174f0faa4 | https://github.com/ulule/limiter/blob/d1a9972e76c234debd9f4cf39c847ea174f0faa4/network.go#L34-L56 | train |
ory/fosite | internal/token_handler.go | NewMockTokenEndpointHandler | func NewMockTokenEndpointHandler(ctrl *gomock.Controller) *MockTokenEndpointHandler {
mock := &MockTokenEndpointHandler{ctrl: ctrl}
mock.recorder = &MockTokenEndpointHandlerMockRecorder{mock}
return mock
} | go | func NewMockTokenEndpointHandler(ctrl *gomock.Controller) *MockTokenEndpointHandler {
mock := &MockTokenEndpointHandler{ctrl: ctrl}
mock.recorder = &MockTokenEndpointHandlerMockRecorder{mock}
return mock
} | [
"func",
"NewMockTokenEndpointHandler",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockTokenEndpointHandler",
"{",
"mock",
":=",
"&",
"MockTokenEndpointHandler",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockTokenEndp... | // NewMockTokenEndpointHandler creates a new mock instance | [
"NewMockTokenEndpointHandler",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/token_handler.go#L28-L32 | train |
ory/fosite | internal/token_handler.go | HandleTokenEndpointRequest | func (m *MockTokenEndpointHandler) HandleTokenEndpointRequest(arg0 context.Context, arg1 fosite.AccessRequester) error {
ret := m.ctrl.Call(m, "HandleTokenEndpointRequest", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockTokenEndpointHandler) HandleTokenEndpointRequest(arg0 context.Context, arg1 fosite.AccessRequester) error {
ret := m.ctrl.Call(m, "HandleTokenEndpointRequest", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTokenEndpointHandler",
")",
"HandleTokenEndpointRequest",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"fosite",
".",
"AccessRequester",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",... | // HandleTokenEndpointRequest mocks base method | [
"HandleTokenEndpointRequest",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/token_handler.go#L40-L44 | train |
ory/fosite | internal/token_handler.go | PopulateTokenEndpointResponse | func (m *MockTokenEndpointHandler) PopulateTokenEndpointResponse(arg0 context.Context, arg1 fosite.AccessRequester, arg2 fosite.AccessResponder) error {
ret := m.ctrl.Call(m, "PopulateTokenEndpointResponse", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockTokenEndpointHandler) PopulateTokenEndpointResponse(arg0 context.Context, arg1 fosite.AccessRequester, arg2 fosite.AccessResponder) error {
ret := m.ctrl.Call(m, "PopulateTokenEndpointResponse", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockTokenEndpointHandler",
")",
"PopulateTokenEndpointResponse",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"fosite",
".",
"AccessRequester",
",",
"arg2",
"fosite",
".",
"AccessResponder",
")",
"error",
"{",
"ret",
":=",
"m",
... | // PopulateTokenEndpointResponse mocks base method | [
"PopulateTokenEndpointResponse",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/token_handler.go#L52-L56 | train |
ory/fosite | internal/token_handler.go | PopulateTokenEndpointResponse | func (mr *MockTokenEndpointHandlerMockRecorder) PopulateTokenEndpointResponse(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PopulateTokenEndpointResponse", reflect.TypeOf((*MockTokenEndpointHandler)(nil).PopulateTokenEndpointResponse), arg0, arg1, arg2)
} | go | func (mr *MockTokenEndpointHandlerMockRecorder) PopulateTokenEndpointResponse(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PopulateTokenEndpointResponse", reflect.TypeOf((*MockTokenEndpointHandler)(nil).PopulateTokenEndpointResponse), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockTokenEndpointHandlerMockRecorder",
")",
"PopulateTokenEndpointResponse",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCa... | // PopulateTokenEndpointResponse indicates an expected call of PopulateTokenEndpointResponse | [
"PopulateTokenEndpointResponse",
"indicates",
"an",
"expected",
"call",
"of",
"PopulateTokenEndpointResponse"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/token_handler.go#L59-L61 | train |
ory/fosite | internal/pkce_storage_strategy.go | NewMockPKCERequestStorage | func NewMockPKCERequestStorage(ctrl *gomock.Controller) *MockPKCERequestStorage {
mock := &MockPKCERequestStorage{ctrl: ctrl}
mock.recorder = &MockPKCERequestStorageMockRecorder{mock}
return mock
} | go | func NewMockPKCERequestStorage(ctrl *gomock.Controller) *MockPKCERequestStorage {
mock := &MockPKCERequestStorage{ctrl: ctrl}
mock.recorder = &MockPKCERequestStorageMockRecorder{mock}
return mock
} | [
"func",
"NewMockPKCERequestStorage",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockPKCERequestStorage",
"{",
"mock",
":=",
"&",
"MockPKCERequestStorage",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockPKCERequestStor... | // NewMockPKCERequestStorage creates a new mock instance | [
"NewMockPKCERequestStorage",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/pkce_storage_strategy.go#L28-L32 | train |
ory/fosite | internal/pkce_storage_strategy.go | DeletePKCERequestSession | func (m *MockPKCERequestStorage) DeletePKCERequestSession(arg0 context.Context, arg1 string) error {
ret := m.ctrl.Call(m, "DeletePKCERequestSession", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockPKCERequestStorage) DeletePKCERequestSession(arg0 context.Context, arg1 string) error {
ret := m.ctrl.Call(m, "DeletePKCERequestSession", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockPKCERequestStorage",
")",
"DeletePKCERequestSession",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"string",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",... | // DeletePKCERequestSession mocks base method | [
"DeletePKCERequestSession",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/pkce_storage_strategy.go#L52-L56 | train |
ory/fosite | internal/pkce_storage_strategy.go | GetPKCERequestSession | func (mr *MockPKCERequestStorageMockRecorder) GetPKCERequestSession(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPKCERequestSession", reflect.TypeOf((*MockPKCERequestStorage)(nil).GetPKCERequestSession), arg0, arg1, arg2)
} | go | func (mr *MockPKCERequestStorageMockRecorder) GetPKCERequestSession(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPKCERequestSession", reflect.TypeOf((*MockPKCERequestStorage)(nil).GetPKCERequestSession), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockPKCERequestStorageMockRecorder",
")",
"GetPKCERequestSession",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMeth... | // GetPKCERequestSession indicates an expected call of GetPKCERequestSession | [
"GetPKCERequestSession",
"indicates",
"an",
"expected",
"call",
"of",
"GetPKCERequestSession"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/pkce_storage_strategy.go#L72-L74 | train |
ory/fosite | compose/compose.go | ComposeAllEnabled | func ComposeAllEnabled(config *Config, storage interface{}, secret []byte, key *rsa.PrivateKey) fosite.OAuth2Provider {
return Compose(
config,
storage,
&CommonStrategy{
CoreStrategy: NewOAuth2HMACStrategy(config, secret, nil),
OpenIDConnectTokenStrategy: NewOpenIDConnectStrategy(config, key),
JWTStrategy: &jwt.RS256JWTStrategy{
PrivateKey: key,
},
},
nil,
OAuth2AuthorizeExplicitFactory,
OAuth2AuthorizeImplicitFactory,
OAuth2ClientCredentialsGrantFactory,
OAuth2RefreshTokenGrantFactory,
OAuth2ResourceOwnerPasswordCredentialsFactory,
OpenIDConnectExplicitFactory,
OpenIDConnectImplicitFactory,
OpenIDConnectHybridFactory,
OpenIDConnectRefreshFactory,
OAuth2TokenIntrospectionFactory,
OAuth2PKCEFactory,
)
} | go | func ComposeAllEnabled(config *Config, storage interface{}, secret []byte, key *rsa.PrivateKey) fosite.OAuth2Provider {
return Compose(
config,
storage,
&CommonStrategy{
CoreStrategy: NewOAuth2HMACStrategy(config, secret, nil),
OpenIDConnectTokenStrategy: NewOpenIDConnectStrategy(config, key),
JWTStrategy: &jwt.RS256JWTStrategy{
PrivateKey: key,
},
},
nil,
OAuth2AuthorizeExplicitFactory,
OAuth2AuthorizeImplicitFactory,
OAuth2ClientCredentialsGrantFactory,
OAuth2RefreshTokenGrantFactory,
OAuth2ResourceOwnerPasswordCredentialsFactory,
OpenIDConnectExplicitFactory,
OpenIDConnectImplicitFactory,
OpenIDConnectHybridFactory,
OpenIDConnectRefreshFactory,
OAuth2TokenIntrospectionFactory,
OAuth2PKCEFactory,
)
} | [
"func",
"ComposeAllEnabled",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"secret",
"[",
"]",
"byte",
",",
"key",
"*",
"rsa",
".",
"PrivateKey",
")",
"fosite",
".",
"OAuth2Provider",
"{",
"return",
"Compose",
"(",
"config",
"... | // ComposeAllEnabled returns a fosite instance with all OAuth2 and OpenID Connect handlers enabled. | [
"ComposeAllEnabled",
"returns",
"a",
"fosite",
"instance",
"with",
"all",
"OAuth2",
"and",
"OpenID",
"Connect",
"handlers",
"enabled",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose.go#L94-L122 | train |
ory/fosite | internal/oauth2_client_storage.go | NewMockClientCredentialsGrantStorage | func NewMockClientCredentialsGrantStorage(ctrl *gomock.Controller) *MockClientCredentialsGrantStorage {
mock := &MockClientCredentialsGrantStorage{ctrl: ctrl}
mock.recorder = &MockClientCredentialsGrantStorageMockRecorder{mock}
return mock
} | go | func NewMockClientCredentialsGrantStorage(ctrl *gomock.Controller) *MockClientCredentialsGrantStorage {
mock := &MockClientCredentialsGrantStorage{ctrl: ctrl}
mock.recorder = &MockClientCredentialsGrantStorageMockRecorder{mock}
return mock
} | [
"func",
"NewMockClientCredentialsGrantStorage",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockClientCredentialsGrantStorage",
"{",
"mock",
":=",
"&",
"MockClientCredentialsGrantStorage",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"... | // NewMockClientCredentialsGrantStorage creates a new mock instance | [
"NewMockClientCredentialsGrantStorage",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/oauth2_client_storage.go#L28-L32 | train |
ory/fosite | internal/oauth2_client_storage.go | GetAccessTokenSession | func (m *MockClientCredentialsGrantStorage) GetAccessTokenSession(arg0 context.Context, arg1 string, arg2 fosite.Session) (fosite.Requester, error) {
ret := m.ctrl.Call(m, "GetAccessTokenSession", arg0, arg1, arg2)
ret0, _ := ret[0].(fosite.Requester)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockClientCredentialsGrantStorage) GetAccessTokenSession(arg0 context.Context, arg1 string, arg2 fosite.Session) (fosite.Requester, error) {
ret := m.ctrl.Call(m, "GetAccessTokenSession", arg0, arg1, arg2)
ret0, _ := ret[0].(fosite.Requester)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockClientCredentialsGrantStorage",
")",
"GetAccessTokenSession",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"string",
",",
"arg2",
"fosite",
".",
"Session",
")",
"(",
"fosite",
".",
"Requester",
",",
"error",
")",
"{",
"ret... | // GetAccessTokenSession mocks base method | [
"GetAccessTokenSession",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/oauth2_client_storage.go#L64-L69 | train |
ory/fosite | compose/compose_pkce.go | OAuth2PKCEFactory | func OAuth2PKCEFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &pkce.Handler{
AuthorizeCodeStrategy: strategy.(oauth2.AuthorizeCodeStrategy),
Storage: storage.(pkce.PKCERequestStorage),
Force: config.EnforcePKCE,
EnablePlainChallengeMethod: config.EnablePKCEPlainChallengeMethod,
}
} | go | func OAuth2PKCEFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &pkce.Handler{
AuthorizeCodeStrategy: strategy.(oauth2.AuthorizeCodeStrategy),
Storage: storage.(pkce.PKCERequestStorage),
Force: config.EnforcePKCE,
EnablePlainChallengeMethod: config.EnablePKCEPlainChallengeMethod,
}
} | [
"func",
"OAuth2PKCEFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"pkce",
".",
"Handler",
"{",
"AuthorizeCodeStrategy",
":",
"strategy",
... | // OAuth2PKCEFactory creates a PKCE handler. | [
"OAuth2PKCEFactory",
"creates",
"a",
"PKCE",
"handler",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_pkce.go#L30-L37 | train |
ory/fosite | internal/client.go | GetHashedSecret | func (m *MockClient) GetHashedSecret() []byte {
ret := m.ctrl.Call(m, "GetHashedSecret")
ret0, _ := ret[0].([]byte)
return ret0
} | go | func (m *MockClient) GetHashedSecret() []byte {
ret := m.ctrl.Call(m, "GetHashedSecret")
ret0, _ := ret[0].([]byte)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockClient",
")",
"GetHashedSecret",
"(",
")",
"[",
"]",
"byte",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"[",
"]"... | // GetHashedSecret mocks base method | [
"GetHashedSecret",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/client.go#L63-L67 | train |
ory/fosite | internal/client.go | IsPublic | func (m *MockClient) IsPublic() bool {
ret := m.ctrl.Call(m, "IsPublic")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockClient) IsPublic() bool {
ret := m.ctrl.Call(m, "IsPublic")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockClient",
")",
"IsPublic",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n",
"retur... | // IsPublic mocks base method | [
"IsPublic",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/client.go#L123-L127 | train |
ory/fosite | token/jwt/jwt.go | Generate | func (j *RS256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error) {
if header == nil || claims == nil {
return "", "", errors.New("Either claims or header is nil.")
}
token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
token.Header = assign(token.Header, header.ToMap())
var sig, sstr string
var err error
if sstr, err = token.SigningString(); err != nil {
return "", "", errors.WithStack(err)
}
if sig, err = token.Method.Sign(sstr, j.PrivateKey); err != nil {
return "", "", errors.WithStack(err)
}
return fmt.Sprintf("%s.%s", sstr, sig), sig, nil
} | go | func (j *RS256JWTStrategy) Generate(ctx context.Context, claims jwt.Claims, header Mapper) (string, string, error) {
if header == nil || claims == nil {
return "", "", errors.New("Either claims or header is nil.")
}
token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
token.Header = assign(token.Header, header.ToMap())
var sig, sstr string
var err error
if sstr, err = token.SigningString(); err != nil {
return "", "", errors.WithStack(err)
}
if sig, err = token.Method.Sign(sstr, j.PrivateKey); err != nil {
return "", "", errors.WithStack(err)
}
return fmt.Sprintf("%s.%s", sstr, sig), sig, nil
} | [
"func",
"(",
"j",
"*",
"RS256JWTStrategy",
")",
"Generate",
"(",
"ctx",
"context",
".",
"Context",
",",
"claims",
"jwt",
".",
"Claims",
",",
"header",
"Mapper",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"if",
"header",
"==",
"nil",
"... | // Generate generates a new authorize code or returns an error. set secret | [
"Generate",
"generates",
"a",
"new",
"authorize",
"code",
"or",
"returns",
"an",
"error",
".",
"set",
"secret"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/token/jwt/jwt.go#L55-L74 | train |
ory/fosite | token/jwt/jwt.go | Decode | func (j *RS256JWTStrategy) Decode(ctx context.Context, token string) (*jwt.Token, error) {
// Parse the token.
parsedToken, err := jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
if _, ok := t.Method.(*jwt.SigningMethodRSA); !ok {
return nil, errors.Errorf("Unexpected signing method: %v", t.Header["alg"])
}
return &j.PrivateKey.PublicKey, nil
})
if err != nil {
return parsedToken, errors.WithStack(err)
} else if !parsedToken.Valid {
return parsedToken, errors.WithStack(fosite.ErrInactiveToken)
}
return parsedToken, err
} | go | func (j *RS256JWTStrategy) Decode(ctx context.Context, token string) (*jwt.Token, error) {
// Parse the token.
parsedToken, err := jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
if _, ok := t.Method.(*jwt.SigningMethodRSA); !ok {
return nil, errors.Errorf("Unexpected signing method: %v", t.Header["alg"])
}
return &j.PrivateKey.PublicKey, nil
})
if err != nil {
return parsedToken, errors.WithStack(err)
} else if !parsedToken.Valid {
return parsedToken, errors.WithStack(fosite.ErrInactiveToken)
}
return parsedToken, err
} | [
"func",
"(",
"j",
"*",
"RS256JWTStrategy",
")",
"Decode",
"(",
"ctx",
"context",
".",
"Context",
",",
"token",
"string",
")",
"(",
"*",
"jwt",
".",
"Token",
",",
"error",
")",
"{",
"// Parse the token.",
"parsedToken",
",",
"err",
":=",
"jwt",
".",
"Pa... | // Decode will decode a JWT token | [
"Decode",
"will",
"decode",
"a",
"JWT",
"token"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/token/jwt/jwt.go#L86-L102 | train |
ory/fosite | token/jwt/jwt.go | GetSignature | func (j *RS256JWTStrategy) GetSignature(ctx context.Context, token string) (string, error) {
split := strings.Split(token, ".")
if len(split) != 3 {
return "", errors.New("Header, body and signature must all be set")
}
return split[2], nil
} | go | func (j *RS256JWTStrategy) GetSignature(ctx context.Context, token string) (string, error) {
split := strings.Split(token, ".")
if len(split) != 3 {
return "", errors.New("Header, body and signature must all be set")
}
return split[2], nil
} | [
"func",
"(",
"j",
"*",
"RS256JWTStrategy",
")",
"GetSignature",
"(",
"ctx",
"context",
".",
"Context",
",",
"token",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"split",
":=",
"strings",
".",
"Split",
"(",
"token",
",",
"\"",
"\"",
")",
"\n... | // GetSignature will return the signature of a token | [
"GetSignature",
"will",
"return",
"the",
"signature",
"of",
"a",
"token"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/token/jwt/jwt.go#L105-L111 | train |
ory/fosite | token/jwt/jwt.go | Hash | func (j *RS256JWTStrategy) Hash(ctx context.Context, in []byte) ([]byte, error) {
// SigningMethodRS256
hash := sha256.New()
_, err := hash.Write(in)
if err != nil {
return []byte{}, errors.WithStack(err)
}
return hash.Sum([]byte{}), nil
} | go | func (j *RS256JWTStrategy) Hash(ctx context.Context, in []byte) ([]byte, error) {
// SigningMethodRS256
hash := sha256.New()
_, err := hash.Write(in)
if err != nil {
return []byte{}, errors.WithStack(err)
}
return hash.Sum([]byte{}), nil
} | [
"func",
"(",
"j",
"*",
"RS256JWTStrategy",
")",
"Hash",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// SigningMethodRS256",
"hash",
":=",
"sha256",
".",
"New",
"(",
")",
"... | // Hash will return a given hash based on the byte input or an error upon fail | [
"Hash",
"will",
"return",
"a",
"given",
"hash",
"based",
"on",
"the",
"byte",
"input",
"or",
"an",
"error",
"upon",
"fail"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/token/jwt/jwt.go#L114-L122 | train |
ory/fosite | storage/transactional.go | MaybeBeginTx | func MaybeBeginTx(ctx context.Context, storage interface{}) (context.Context, error) {
// the type assertion checks whether the dynamic type of `storage` implements `Transactional`
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.BeginTX(ctx)
} else {
return ctx, nil
}
} | go | func MaybeBeginTx(ctx context.Context, storage interface{}) (context.Context, error) {
// the type assertion checks whether the dynamic type of `storage` implements `Transactional`
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.BeginTX(ctx)
} else {
return ctx, nil
}
} | [
"func",
"MaybeBeginTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"storage",
"interface",
"{",
"}",
")",
"(",
"context",
".",
"Context",
",",
"error",
")",
"{",
"// the type assertion checks whether the dynamic type of `storage` implements `Transactional`",
"txnStorage"... | // MaybeBeginTx is a helper function that can be used to initiate a transaction if the supplied storage
// implements the `Transactional` interface. | [
"MaybeBeginTx",
"is",
"a",
"helper",
"function",
"that",
"can",
"be",
"used",
"to",
"initiate",
"a",
"transaction",
"if",
"the",
"supplied",
"storage",
"implements",
"the",
"Transactional",
"interface",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/storage/transactional.go#L25-L33 | train |
ory/fosite | storage/transactional.go | MaybeCommitTx | func MaybeCommitTx(ctx context.Context, storage interface{}) error {
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.Commit(ctx)
} else {
return nil
}
} | go | func MaybeCommitTx(ctx context.Context, storage interface{}) error {
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.Commit(ctx)
} else {
return nil
}
} | [
"func",
"MaybeCommitTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"storage",
"interface",
"{",
"}",
")",
"error",
"{",
"txnStorage",
",",
"transactional",
":=",
"storage",
".",
"(",
"Transactional",
")",
"\n",
"if",
"transactional",
"{",
"return",
"txnSto... | // MaybeCommitTx is a helper function that can be used to commit a transaction if the supplied storage
// implements the `Transactional` interface. | [
"MaybeCommitTx",
"is",
"a",
"helper",
"function",
"that",
"can",
"be",
"used",
"to",
"commit",
"a",
"transaction",
"if",
"the",
"supplied",
"storage",
"implements",
"the",
"Transactional",
"interface",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/storage/transactional.go#L37-L44 | train |
ory/fosite | storage/transactional.go | MaybeRollbackTx | func MaybeRollbackTx(ctx context.Context, storage interface{}) error {
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.Rollback(ctx)
} else {
return nil
}
} | go | func MaybeRollbackTx(ctx context.Context, storage interface{}) error {
txnStorage, transactional := storage.(Transactional)
if transactional {
return txnStorage.Rollback(ctx)
} else {
return nil
}
} | [
"func",
"MaybeRollbackTx",
"(",
"ctx",
"context",
".",
"Context",
",",
"storage",
"interface",
"{",
"}",
")",
"error",
"{",
"txnStorage",
",",
"transactional",
":=",
"storage",
".",
"(",
"Transactional",
")",
"\n",
"if",
"transactional",
"{",
"return",
"txnS... | // MaybeRollbackTx is a helper function that can be used to rollback a transaction if the supplied storage
// implements the `Transactional` interface. | [
"MaybeRollbackTx",
"is",
"a",
"helper",
"function",
"that",
"can",
"be",
"used",
"to",
"rollback",
"a",
"transaction",
"if",
"the",
"supplied",
"storage",
"implements",
"the",
"Transactional",
"interface",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/storage/transactional.go#L48-L55 | train |
ory/fosite | internal/authorize_request.go | NewMockAuthorizeRequester | func NewMockAuthorizeRequester(ctrl *gomock.Controller) *MockAuthorizeRequester {
mock := &MockAuthorizeRequester{ctrl: ctrl}
mock.recorder = &MockAuthorizeRequesterMockRecorder{mock}
return mock
} | go | func NewMockAuthorizeRequester(ctrl *gomock.Controller) *MockAuthorizeRequester {
mock := &MockAuthorizeRequester{ctrl: ctrl}
mock.recorder = &MockAuthorizeRequesterMockRecorder{mock}
return mock
} | [
"func",
"NewMockAuthorizeRequester",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAuthorizeRequester",
"{",
"mock",
":=",
"&",
"MockAuthorizeRequester",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAuthorizeReques... | // NewMockAuthorizeRequester creates a new mock instance | [
"NewMockAuthorizeRequester",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_request.go#L29-L33 | train |
ory/fosite | internal/authorize_request.go | GetRedirectURI | func (m *MockAuthorizeRequester) GetRedirectURI() *url.URL {
ret := m.ctrl.Call(m, "GetRedirectURI")
ret0, _ := ret[0].(*url.URL)
return ret0
} | go | func (m *MockAuthorizeRequester) GetRedirectURI() *url.URL {
ret := m.ctrl.Call(m, "GetRedirectURI")
ret0, _ := ret[0].(*url.URL)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeRequester",
")",
"GetRedirectURI",
"(",
")",
"*",
"url",
".",
"URL",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
... | // GetRedirectURI mocks base method | [
"GetRedirectURI",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_request.go#L111-L115 | train |
ory/fosite | internal/authorize_request.go | GetRequestForm | func (m *MockAuthorizeRequester) GetRequestForm() url.Values {
ret := m.ctrl.Call(m, "GetRequestForm")
ret0, _ := ret[0].(url.Values)
return ret0
} | go | func (m *MockAuthorizeRequester) GetRequestForm() url.Values {
ret := m.ctrl.Call(m, "GetRequestForm")
ret0, _ := ret[0].(url.Values)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeRequester",
")",
"GetRequestForm",
"(",
")",
"url",
".",
"Values",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(... | // GetRequestForm mocks base method | [
"GetRequestForm",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_request.go#L123-L127 | train |
ory/fosite | internal/authorize_request.go | IsRedirectURIValid | func (m *MockAuthorizeRequester) IsRedirectURIValid() bool {
ret := m.ctrl.Call(m, "IsRedirectURIValid")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockAuthorizeRequester) IsRedirectURIValid() bool {
ret := m.ctrl.Call(m, "IsRedirectURIValid")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeRequester",
")",
"IsRedirectURIValid",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
... | // IsRedirectURIValid mocks base method | [
"IsRedirectURIValid",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_request.go#L227-L231 | train |
ory/fosite | internal/authorize_request.go | SetResponseTypeHandled | func (m *MockAuthorizeRequester) SetResponseTypeHandled(arg0 string) {
m.ctrl.Call(m, "SetResponseTypeHandled", arg0)
} | go | func (m *MockAuthorizeRequester) SetResponseTypeHandled(arg0 string) {
m.ctrl.Call(m, "SetResponseTypeHandled", arg0)
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeRequester",
")",
"SetResponseTypeHandled",
"(",
"arg0",
"string",
")",
"{",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"}"
] | // SetResponseTypeHandled mocks base method | [
"SetResponseTypeHandled",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_request.go#L291-L293 | train |
ory/fosite | token/jwt/claims_jwt.go | FromMap | func (c *JWTClaims) FromMap(m map[string]interface{}) {
c.Extra = make(map[string]interface{})
for k, v := range m {
switch k {
case "jti":
if s, ok := v.(string); ok {
c.JTI = s
}
case "sub":
if s, ok := v.(string); ok {
c.Subject = s
}
case "iss":
if s, ok := v.(string); ok {
c.Issuer = s
}
case "aud":
if s, ok := v.(string); ok {
c.Audience = []string{s}
} else if s, ok := v.([]string); ok {
c.Audience = s
}
case "iat":
switch v.(type) {
case float64:
c.IssuedAt = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.IssuedAt = time.Unix(v.(int64), 0).UTC()
}
case "nbf":
switch v.(type) {
case float64:
c.NotBefore = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.NotBefore = time.Unix(v.(int64), 0).UTC()
}
case "exp":
switch v.(type) {
case float64:
c.ExpiresAt = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.ExpiresAt = time.Unix(v.(int64), 0).UTC()
}
case "scp":
switch v.(type) {
case []string:
c.Scope = v.([]string)
case []interface{}:
c.Scope = make([]string, len(v.([]interface{})))
for i, vi := range v.([]interface{}) {
if s, ok := vi.(string); ok {
c.Scope[i] = s
}
}
}
default:
c.Extra[k] = v
}
}
} | go | func (c *JWTClaims) FromMap(m map[string]interface{}) {
c.Extra = make(map[string]interface{})
for k, v := range m {
switch k {
case "jti":
if s, ok := v.(string); ok {
c.JTI = s
}
case "sub":
if s, ok := v.(string); ok {
c.Subject = s
}
case "iss":
if s, ok := v.(string); ok {
c.Issuer = s
}
case "aud":
if s, ok := v.(string); ok {
c.Audience = []string{s}
} else if s, ok := v.([]string); ok {
c.Audience = s
}
case "iat":
switch v.(type) {
case float64:
c.IssuedAt = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.IssuedAt = time.Unix(v.(int64), 0).UTC()
}
case "nbf":
switch v.(type) {
case float64:
c.NotBefore = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.NotBefore = time.Unix(v.(int64), 0).UTC()
}
case "exp":
switch v.(type) {
case float64:
c.ExpiresAt = time.Unix(int64(v.(float64)), 0).UTC()
case int64:
c.ExpiresAt = time.Unix(v.(int64), 0).UTC()
}
case "scp":
switch v.(type) {
case []string:
c.Scope = v.([]string)
case []interface{}:
c.Scope = make([]string, len(v.([]interface{})))
for i, vi := range v.([]interface{}) {
if s, ok := vi.(string); ok {
c.Scope[i] = s
}
}
}
default:
c.Extra[k] = v
}
}
} | [
"func",
"(",
"c",
"*",
"JWTClaims",
")",
"FromMap",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"Extra",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"for",
"k",
",",
"v",
... | // FromMap will set the claims based on a mapping | [
"FromMap",
"will",
"set",
"the",
"claims",
"based",
"on",
"a",
"mapping"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/token/jwt/claims_jwt.go#L112-L171 | train |
ory/fosite | internal/access_token_strategy.go | NewMockAccessTokenStrategy | func NewMockAccessTokenStrategy(ctrl *gomock.Controller) *MockAccessTokenStrategy {
mock := &MockAccessTokenStrategy{ctrl: ctrl}
mock.recorder = &MockAccessTokenStrategyMockRecorder{mock}
return mock
} | go | func NewMockAccessTokenStrategy(ctrl *gomock.Controller) *MockAccessTokenStrategy {
mock := &MockAccessTokenStrategy{ctrl: ctrl}
mock.recorder = &MockAccessTokenStrategyMockRecorder{mock}
return mock
} | [
"func",
"NewMockAccessTokenStrategy",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAccessTokenStrategy",
"{",
"mock",
":=",
"&",
"MockAccessTokenStrategy",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAccessTokenS... | // NewMockAccessTokenStrategy creates a new mock instance | [
"NewMockAccessTokenStrategy",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_token_strategy.go#L28-L32 | train |
ory/fosite | internal/authorize_code_storage.go | NewMockAuthorizeCodeStorage | func NewMockAuthorizeCodeStorage(ctrl *gomock.Controller) *MockAuthorizeCodeStorage {
mock := &MockAuthorizeCodeStorage{ctrl: ctrl}
mock.recorder = &MockAuthorizeCodeStorageMockRecorder{mock}
return mock
} | go | func NewMockAuthorizeCodeStorage(ctrl *gomock.Controller) *MockAuthorizeCodeStorage {
mock := &MockAuthorizeCodeStorage{ctrl: ctrl}
mock.recorder = &MockAuthorizeCodeStorageMockRecorder{mock}
return mock
} | [
"func",
"NewMockAuthorizeCodeStorage",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAuthorizeCodeStorage",
"{",
"mock",
":=",
"&",
"MockAuthorizeCodeStorage",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAuthorize... | // NewMockAuthorizeCodeStorage creates a new mock instance | [
"NewMockAuthorizeCodeStorage",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_storage.go#L28-L32 | train |
ory/fosite | internal/authorize_code_storage.go | CreateAuthorizeCodeSession | func (mr *MockAuthorizeCodeStorageMockRecorder) CreateAuthorizeCodeSession(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuthorizeCodeSession", reflect.TypeOf((*MockAuthorizeCodeStorage)(nil).CreateAuthorizeCodeSession), arg0, arg1, arg2)
} | go | func (mr *MockAuthorizeCodeStorageMockRecorder) CreateAuthorizeCodeSession(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAuthorizeCodeSession", reflect.TypeOf((*MockAuthorizeCodeStorage)(nil).CreateAuthorizeCodeSession), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockAuthorizeCodeStorageMockRecorder",
")",
"CreateAuthorizeCodeSession",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallW... | // CreateAuthorizeCodeSession indicates an expected call of CreateAuthorizeCodeSession | [
"CreateAuthorizeCodeSession",
"indicates",
"an",
"expected",
"call",
"of",
"CreateAuthorizeCodeSession"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_storage.go#L47-L49 | train |
ory/fosite | internal/authorize_code_strategy.go | NewMockAuthorizeCodeStrategy | func NewMockAuthorizeCodeStrategy(ctrl *gomock.Controller) *MockAuthorizeCodeStrategy {
mock := &MockAuthorizeCodeStrategy{ctrl: ctrl}
mock.recorder = &MockAuthorizeCodeStrategyMockRecorder{mock}
return mock
} | go | func NewMockAuthorizeCodeStrategy(ctrl *gomock.Controller) *MockAuthorizeCodeStrategy {
mock := &MockAuthorizeCodeStrategy{ctrl: ctrl}
mock.recorder = &MockAuthorizeCodeStrategyMockRecorder{mock}
return mock
} | [
"func",
"NewMockAuthorizeCodeStrategy",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAuthorizeCodeStrategy",
"{",
"mock",
":=",
"&",
"MockAuthorizeCodeStrategy",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAuthor... | // NewMockAuthorizeCodeStrategy creates a new mock instance | [
"NewMockAuthorizeCodeStrategy",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_strategy.go#L28-L32 | train |
ory/fosite | internal/authorize_code_strategy.go | AuthorizeCodeSignature | func (m *MockAuthorizeCodeStrategy) AuthorizeCodeSignature(arg0 string) string {
ret := m.ctrl.Call(m, "AuthorizeCodeSignature", arg0)
ret0, _ := ret[0].(string)
return ret0
} | go | func (m *MockAuthorizeCodeStrategy) AuthorizeCodeSignature(arg0 string) string {
ret := m.ctrl.Call(m, "AuthorizeCodeSignature", arg0)
ret0, _ := ret[0].(string)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeCodeStrategy",
")",
"AuthorizeCodeSignature",
"(",
"arg0",
"string",
")",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret"... | // AuthorizeCodeSignature mocks base method | [
"AuthorizeCodeSignature",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_strategy.go#L40-L44 | train |
ory/fosite | internal/authorize_code_strategy.go | AuthorizeCodeSignature | func (mr *MockAuthorizeCodeStrategyMockRecorder) AuthorizeCodeSignature(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthorizeCodeSignature", reflect.TypeOf((*MockAuthorizeCodeStrategy)(nil).AuthorizeCodeSignature), arg0)
} | go | func (mr *MockAuthorizeCodeStrategyMockRecorder) AuthorizeCodeSignature(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthorizeCodeSignature", reflect.TypeOf((*MockAuthorizeCodeStrategy)(nil).AuthorizeCodeSignature), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockAuthorizeCodeStrategyMockRecorder",
")",
"AuthorizeCodeSignature",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",... | // AuthorizeCodeSignature indicates an expected call of AuthorizeCodeSignature | [
"AuthorizeCodeSignature",
"indicates",
"an",
"expected",
"call",
"of",
"AuthorizeCodeSignature"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_strategy.go#L47-L49 | train |
ory/fosite | internal/authorize_code_strategy.go | GenerateAuthorizeCode | func (m *MockAuthorizeCodeStrategy) GenerateAuthorizeCode(arg0 context.Context, arg1 fosite.Requester) (string, string, error) {
ret := m.ctrl.Call(m, "GenerateAuthorizeCode", arg0, arg1)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(string)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | go | func (m *MockAuthorizeCodeStrategy) GenerateAuthorizeCode(arg0 context.Context, arg1 fosite.Requester) (string, string, error) {
ret := m.ctrl.Call(m, "GenerateAuthorizeCode", arg0, arg1)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(string)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeCodeStrategy",
")",
"GenerateAuthorizeCode",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"fosite",
".",
"Requester",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
"... | // GenerateAuthorizeCode mocks base method | [
"GenerateAuthorizeCode",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_strategy.go#L52-L58 | train |
ory/fosite | internal/authorize_code_strategy.go | ValidateAuthorizeCode | func (m *MockAuthorizeCodeStrategy) ValidateAuthorizeCode(arg0 context.Context, arg1 fosite.Requester, arg2 string) error {
ret := m.ctrl.Call(m, "ValidateAuthorizeCode", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockAuthorizeCodeStrategy) ValidateAuthorizeCode(arg0 context.Context, arg1 fosite.Requester, arg2 string) error {
ret := m.ctrl.Call(m, "ValidateAuthorizeCode", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizeCodeStrategy",
")",
"ValidateAuthorizeCode",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"fosite",
".",
"Requester",
",",
"arg2",
"string",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
... | // ValidateAuthorizeCode mocks base method | [
"ValidateAuthorizeCode",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/authorize_code_strategy.go#L66-L70 | train |
ory/fosite | internal/hash.go | NewMockHasher | func NewMockHasher(ctrl *gomock.Controller) *MockHasher {
mock := &MockHasher{ctrl: ctrl}
mock.recorder = &MockHasherMockRecorder{mock}
return mock
} | go | func NewMockHasher(ctrl *gomock.Controller) *MockHasher {
mock := &MockHasher{ctrl: ctrl}
mock.recorder = &MockHasherMockRecorder{mock}
return mock
} | [
"func",
"NewMockHasher",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockHasher",
"{",
"mock",
":=",
"&",
"MockHasher",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockHasherMockRecorder",
"{",
"mock",
"}",
"\n"... | // NewMockHasher creates a new mock instance | [
"NewMockHasher",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/hash.go#L26-L30 | train |
ory/fosite | internal/hash.go | Compare | func (m *MockHasher) Compare(arg0 context.Context, arg1, arg2 []byte) error {
ret := m.ctrl.Call(m, "Compare", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockHasher) Compare(arg0 context.Context, arg1, arg2 []byte) error {
ret := m.ctrl.Call(m, "Compare", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockHasher",
")",
"Compare",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
",",
"arg2",
"[",
"]",
"byte",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",... | // Compare mocks base method | [
"Compare",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/hash.go#L38-L42 | train |
ory/fosite | internal/hash.go | Compare | func (mr *MockHasherMockRecorder) Compare(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Compare", reflect.TypeOf((*MockHasher)(nil).Compare), arg0, arg1, arg2)
} | go | func (mr *MockHasherMockRecorder) Compare(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Compare", reflect.TypeOf((*MockHasher)(nil).Compare), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockHasherMockRecorder",
")",
"Compare",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
... | // Compare indicates an expected call of Compare | [
"Compare",
"indicates",
"an",
"expected",
"call",
"of",
"Compare"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/hash.go#L45-L47 | train |
ory/fosite | internal/hash.go | Hash | func (m *MockHasher) Hash(arg0 context.Context, arg1 []byte) ([]byte, error) {
ret := m.ctrl.Call(m, "Hash", arg0, arg1)
ret0, _ := ret[0].([]byte)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockHasher) Hash(arg0 context.Context, arg1 []byte) ([]byte, error) {
ret := m.ctrl.Call(m, "Hash", arg0, arg1)
ret0, _ := ret[0].([]byte)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockHasher",
")",
"Hash",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\""... | // Hash mocks base method | [
"Hash",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/hash.go#L50-L55 | train |
ory/fosite | internal/oauth2_revoke_storage.go | NewMockTokenRevocationStorage | func NewMockTokenRevocationStorage(ctrl *gomock.Controller) *MockTokenRevocationStorage {
mock := &MockTokenRevocationStorage{ctrl: ctrl}
mock.recorder = &MockTokenRevocationStorageMockRecorder{mock}
return mock
} | go | func NewMockTokenRevocationStorage(ctrl *gomock.Controller) *MockTokenRevocationStorage {
mock := &MockTokenRevocationStorage{ctrl: ctrl}
mock.recorder = &MockTokenRevocationStorageMockRecorder{mock}
return mock
} | [
"func",
"NewMockTokenRevocationStorage",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockTokenRevocationStorage",
"{",
"mock",
":=",
"&",
"MockTokenRevocationStorage",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockTok... | // NewMockTokenRevocationStorage creates a new mock instance | [
"NewMockTokenRevocationStorage",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/oauth2_revoke_storage.go#L28-L32 | train |
ory/fosite | internal/oauth2_revoke_storage.go | RevokeRefreshToken | func (mr *MockTokenRevocationStorageMockRecorder) RevokeRefreshToken(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeRefreshToken", reflect.TypeOf((*MockTokenRevocationStorage)(nil).RevokeRefreshToken), arg0, arg1)
} | go | func (mr *MockTokenRevocationStorageMockRecorder) RevokeRefreshToken(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeRefreshToken", reflect.TypeOf((*MockTokenRevocationStorage)(nil).RevokeRefreshToken), arg0, arg1)
} | [
"func",
"(",
"mr",
"*",
"MockTokenRevocationStorageMockRecorder",
")",
"RevokeRefreshToken",
"(",
"arg0",
",",
"arg1",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
... | // RevokeRefreshToken indicates an expected call of RevokeRefreshToken | [
"RevokeRefreshToken",
"indicates",
"an",
"expected",
"call",
"of",
"RevokeRefreshToken"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/oauth2_revoke_storage.go#L133-L135 | train |
ory/fosite | internal/access_token_storage.go | NewMockAccessTokenStorage | func NewMockAccessTokenStorage(ctrl *gomock.Controller) *MockAccessTokenStorage {
mock := &MockAccessTokenStorage{ctrl: ctrl}
mock.recorder = &MockAccessTokenStorageMockRecorder{mock}
return mock
} | go | func NewMockAccessTokenStorage(ctrl *gomock.Controller) *MockAccessTokenStorage {
mock := &MockAccessTokenStorage{ctrl: ctrl}
mock.recorder = &MockAccessTokenStorageMockRecorder{mock}
return mock
} | [
"func",
"NewMockAccessTokenStorage",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAccessTokenStorage",
"{",
"mock",
":=",
"&",
"MockAccessTokenStorage",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAccessTokenStor... | // NewMockAccessTokenStorage creates a new mock instance | [
"NewMockAccessTokenStorage",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/access_token_storage.go#L28-L32 | train |
ory/fosite | compose/config.go | GetScopeStrategy | func (c *Config) GetScopeStrategy() fosite.ScopeStrategy {
if c.ScopeStrategy == nil {
c.ScopeStrategy = fosite.WildcardScopeStrategy
}
return c.ScopeStrategy
} | go | func (c *Config) GetScopeStrategy() fosite.ScopeStrategy {
if c.ScopeStrategy == nil {
c.ScopeStrategy = fosite.WildcardScopeStrategy
}
return c.ScopeStrategy
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetScopeStrategy",
"(",
")",
"fosite",
".",
"ScopeStrategy",
"{",
"if",
"c",
".",
"ScopeStrategy",
"==",
"nil",
"{",
"c",
".",
"ScopeStrategy",
"=",
"fosite",
".",
"WildcardScopeStrategy",
"\n",
"}",
"\n",
"return",
... | // GetScopeStrategy returns the scope strategy to be used. Defaults to glob scope strategy. | [
"GetScopeStrategy",
"returns",
"the",
"scope",
"strategy",
"to",
"be",
"used",
".",
"Defaults",
"to",
"glob",
"scope",
"strategy",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L92-L97 | train |
ory/fosite | compose/config.go | GetAudienceStrategy | func (c *Config) GetAudienceStrategy() fosite.AudienceMatchingStrategy {
if c.AudienceMatchingStrategy == nil {
c.AudienceMatchingStrategy = fosite.DefaultAudienceMatchingStrategy
}
return c.AudienceMatchingStrategy
} | go | func (c *Config) GetAudienceStrategy() fosite.AudienceMatchingStrategy {
if c.AudienceMatchingStrategy == nil {
c.AudienceMatchingStrategy = fosite.DefaultAudienceMatchingStrategy
}
return c.AudienceMatchingStrategy
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetAudienceStrategy",
"(",
")",
"fosite",
".",
"AudienceMatchingStrategy",
"{",
"if",
"c",
".",
"AudienceMatchingStrategy",
"==",
"nil",
"{",
"c",
".",
"AudienceMatchingStrategy",
"=",
"fosite",
".",
"DefaultAudienceMatchingS... | // GetAudienceStrategy returns the scope strategy to be used. Defaults to glob scope strategy. | [
"GetAudienceStrategy",
"returns",
"the",
"scope",
"strategy",
"to",
"be",
"used",
".",
"Defaults",
"to",
"glob",
"scope",
"strategy",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L100-L105 | train |
ory/fosite | compose/config.go | GetAuthorizeCodeLifespan | func (c *Config) GetAuthorizeCodeLifespan() time.Duration {
if c.AuthorizeCodeLifespan == 0 {
return time.Minute * 15
}
return c.AuthorizeCodeLifespan
} | go | func (c *Config) GetAuthorizeCodeLifespan() time.Duration {
if c.AuthorizeCodeLifespan == 0 {
return time.Minute * 15
}
return c.AuthorizeCodeLifespan
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetAuthorizeCodeLifespan",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"c",
".",
"AuthorizeCodeLifespan",
"==",
"0",
"{",
"return",
"time",
".",
"Minute",
"*",
"15",
"\n",
"}",
"\n",
"return",
"c",
".",
"Authori... | // GetAuthorizeCodeLifespan returns how long an authorize code should be valid. Defaults to one fifteen minutes. | [
"GetAuthorizeCodeLifespan",
"returns",
"how",
"long",
"an",
"authorize",
"code",
"should",
"be",
"valid",
".",
"Defaults",
"to",
"one",
"fifteen",
"minutes",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L108-L113 | train |
ory/fosite | compose/config.go | GetIDTokenLifespan | func (c *Config) GetIDTokenLifespan() time.Duration {
if c.IDTokenLifespan == 0 {
return time.Hour
}
return c.IDTokenLifespan
} | go | func (c *Config) GetIDTokenLifespan() time.Duration {
if c.IDTokenLifespan == 0 {
return time.Hour
}
return c.IDTokenLifespan
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetIDTokenLifespan",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"c",
".",
"IDTokenLifespan",
"==",
"0",
"{",
"return",
"time",
".",
"Hour",
"\n",
"}",
"\n",
"return",
"c",
".",
"IDTokenLifespan",
"\n",
"}"
] | // GeIDTokenLifespan returns how long an id token should be valid. Defaults to one hour. | [
"GeIDTokenLifespan",
"returns",
"how",
"long",
"an",
"id",
"token",
"should",
"be",
"valid",
".",
"Defaults",
"to",
"one",
"hour",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L116-L121 | train |
ory/fosite | compose/config.go | GetAccessTokenLifespan | func (c *Config) GetAccessTokenLifespan() time.Duration {
if c.AccessTokenLifespan == 0 {
return time.Hour
}
return c.AccessTokenLifespan
} | go | func (c *Config) GetAccessTokenLifespan() time.Duration {
if c.AccessTokenLifespan == 0 {
return time.Hour
}
return c.AccessTokenLifespan
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetAccessTokenLifespan",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"c",
".",
"AccessTokenLifespan",
"==",
"0",
"{",
"return",
"time",
".",
"Hour",
"\n",
"}",
"\n",
"return",
"c",
".",
"AccessTokenLifespan",
"\n"... | // GetAccessTokenLifespan returns how long an access token should be valid. Defaults to one hour. | [
"GetAccessTokenLifespan",
"returns",
"how",
"long",
"an",
"access",
"token",
"should",
"be",
"valid",
".",
"Defaults",
"to",
"one",
"hour",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L124-L129 | train |
ory/fosite | compose/config.go | GetRefreshTokenLifespan | func (c *Config) GetRefreshTokenLifespan() time.Duration {
if c.RefreshTokenLifespan == 0 {
return time.Hour * 24 * 30
}
return c.RefreshTokenLifespan
} | go | func (c *Config) GetRefreshTokenLifespan() time.Duration {
if c.RefreshTokenLifespan == 0 {
return time.Hour * 24 * 30
}
return c.RefreshTokenLifespan
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetRefreshTokenLifespan",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"c",
".",
"RefreshTokenLifespan",
"==",
"0",
"{",
"return",
"time",
".",
"Hour",
"*",
"24",
"*",
"30",
"\n",
"}",
"\n",
"return",
"c",
".",... | // GetRefreshTokenLifespan sets how long a refresh token is going to be valid. Defaults to 30 days. Set to -1 for
// refresh tokens that never expire. | [
"GetRefreshTokenLifespan",
"sets",
"how",
"long",
"a",
"refresh",
"token",
"is",
"going",
"to",
"be",
"valid",
".",
"Defaults",
"to",
"30",
"days",
".",
"Set",
"to",
"-",
"1",
"for",
"refresh",
"tokens",
"that",
"never",
"expire",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L133-L138 | train |
ory/fosite | compose/config.go | GetHashCost | func (c *Config) GetHashCost() int {
if c.HashCost == 0 {
return fosite.DefaultBCryptWorkFactor
}
return c.HashCost
} | go | func (c *Config) GetHashCost() int {
if c.HashCost == 0 {
return fosite.DefaultBCryptWorkFactor
}
return c.HashCost
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetHashCost",
"(",
")",
"int",
"{",
"if",
"c",
".",
"HashCost",
"==",
"0",
"{",
"return",
"fosite",
".",
"DefaultBCryptWorkFactor",
"\n",
"}",
"\n",
"return",
"c",
".",
"HashCost",
"\n",
"}"
] | // GetHashCost returns the bcrypt cost factor. Defaults to 12. | [
"GetHashCost",
"returns",
"the",
"bcrypt",
"cost",
"factor",
".",
"Defaults",
"to",
"12",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L141-L146 | train |
ory/fosite | compose/config.go | GetJWKSFetcherStrategy | func (c *Config) GetJWKSFetcherStrategy() fosite.JWKSFetcherStrategy {
if c.JWKSFetcher == nil {
c.JWKSFetcher = fosite.NewDefaultJWKSFetcherStrategy()
}
return c.JWKSFetcher
} | go | func (c *Config) GetJWKSFetcherStrategy() fosite.JWKSFetcherStrategy {
if c.JWKSFetcher == nil {
c.JWKSFetcher = fosite.NewDefaultJWKSFetcherStrategy()
}
return c.JWKSFetcher
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetJWKSFetcherStrategy",
"(",
")",
"fosite",
".",
"JWKSFetcherStrategy",
"{",
"if",
"c",
".",
"JWKSFetcher",
"==",
"nil",
"{",
"c",
".",
"JWKSFetcher",
"=",
"fosite",
".",
"NewDefaultJWKSFetcherStrategy",
"(",
")",
"\n"... | // GetJWKSFetcherStrategy returns the JWKSFetcherStrategy. | [
"GetJWKSFetcherStrategy",
"returns",
"the",
"JWKSFetcherStrategy",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L149-L154 | train |
ory/fosite | compose/config.go | GetRedirectSecureChecker | func (c *Config) GetRedirectSecureChecker() func(*url.URL) bool {
if c.RedirectSecureChecker == nil {
return fosite.IsRedirectURISecure
}
return c.RedirectSecureChecker
} | go | func (c *Config) GetRedirectSecureChecker() func(*url.URL) bool {
if c.RedirectSecureChecker == nil {
return fosite.IsRedirectURISecure
}
return c.RedirectSecureChecker
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetRedirectSecureChecker",
"(",
")",
"func",
"(",
"*",
"url",
".",
"URL",
")",
"bool",
"{",
"if",
"c",
".",
"RedirectSecureChecker",
"==",
"nil",
"{",
"return",
"fosite",
".",
"IsRedirectURISecure",
"\n",
"}",
"\n",... | // GetTokenEntropy returns the entropy of the "message" part of a HMAC Token. Defaults to 32. | [
"GetTokenEntropy",
"returns",
"the",
"entropy",
"of",
"the",
"message",
"part",
"of",
"a",
"HMAC",
"Token",
".",
"Defaults",
"to",
"32",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/config.go#L165-L170 | train |
ory/fosite | internal/introspector.go | NewMockTokenIntrospector | func NewMockTokenIntrospector(ctrl *gomock.Controller) *MockTokenIntrospector {
mock := &MockTokenIntrospector{ctrl: ctrl}
mock.recorder = &MockTokenIntrospectorMockRecorder{mock}
return mock
} | go | func NewMockTokenIntrospector(ctrl *gomock.Controller) *MockTokenIntrospector {
mock := &MockTokenIntrospector{ctrl: ctrl}
mock.recorder = &MockTokenIntrospectorMockRecorder{mock}
return mock
} | [
"func",
"NewMockTokenIntrospector",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockTokenIntrospector",
"{",
"mock",
":=",
"&",
"MockTokenIntrospector",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockTokenIntrospectorM... | // NewMockTokenIntrospector creates a new mock instance | [
"NewMockTokenIntrospector",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/introspector.go#L28-L32 | train |
ory/fosite | internal/introspector.go | IntrospectToken | func (m *MockTokenIntrospector) IntrospectToken(arg0 context.Context, arg1 string, arg2 fosite.TokenType, arg3 fosite.AccessRequester, arg4 []string) (fosite.TokenType, error) {
ret := m.ctrl.Call(m, "IntrospectToken", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(fosite.TokenType)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockTokenIntrospector) IntrospectToken(arg0 context.Context, arg1 string, arg2 fosite.TokenType, arg3 fosite.AccessRequester, arg4 []string) (fosite.TokenType, error) {
ret := m.ctrl.Call(m, "IntrospectToken", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].(fosite.TokenType)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockTokenIntrospector",
")",
"IntrospectToken",
"(",
"arg0",
"context",
".",
"Context",
",",
"arg1",
"string",
",",
"arg2",
"fosite",
".",
"TokenType",
",",
"arg3",
"fosite",
".",
"AccessRequester",
",",
"arg4",
"[",
"]",
"string",
... | // IntrospectToken mocks base method | [
"IntrospectToken",
"mocks",
"base",
"method"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/introspector.go#L40-L45 | train |
ory/fosite | internal/introspector.go | IntrospectToken | func (mr *MockTokenIntrospectorMockRecorder) IntrospectToken(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IntrospectToken", reflect.TypeOf((*MockTokenIntrospector)(nil).IntrospectToken), arg0, arg1, arg2, arg3, arg4)
} | go | func (mr *MockTokenIntrospectorMockRecorder) IntrospectToken(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IntrospectToken", reflect.TypeOf((*MockTokenIntrospector)(nil).IntrospectToken), arg0, arg1, arg2, arg3, arg4)
} | [
"func",
"(",
"mr",
"*",
"MockTokenIntrospectorMockRecorder",
")",
"IntrospectToken",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
",",
"arg3",
",",
"arg4",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
... | // IntrospectToken indicates an expected call of IntrospectToken | [
"IntrospectToken",
"indicates",
"an",
"expected",
"call",
"of",
"IntrospectToken"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/introspector.go#L48-L50 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2ClientCredentialsGrantFactory | func OAuth2ClientCredentialsGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.ClientCredentialsGrantHandler{
HandleHelper: &oauth2.HandleHelper{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
AccessTokenStorage: storage.(oauth2.AccessTokenStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
},
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | go | func OAuth2ClientCredentialsGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.ClientCredentialsGrantHandler{
HandleHelper: &oauth2.HandleHelper{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
AccessTokenStorage: storage.(oauth2.AccessTokenStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
},
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | [
"func",
"OAuth2ClientCredentialsGrantFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"ClientCredentialsGrantHandler",
"{",
"Hand... | // OAuth2ClientCredentialsGrantFactory creates an OAuth2 client credentials grant handler and registers
// an access token, refresh token and authorize code validator. | [
"OAuth2ClientCredentialsGrantFactory",
"creates",
"an",
"OAuth2",
"client",
"credentials",
"grant",
"handler",
"and",
"registers",
"an",
"access",
"token",
"refresh",
"token",
"and",
"authorize",
"code",
"validator",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L48-L58 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2RefreshTokenGrantFactory | func OAuth2RefreshTokenGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.RefreshTokenGrantHandler{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
TokenRevocationStorage: storage.(oauth2.TokenRevocationStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
RefreshTokenLifespan: config.GetRefreshTokenLifespan(),
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | go | func OAuth2RefreshTokenGrantFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.RefreshTokenGrantHandler{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
TokenRevocationStorage: storage.(oauth2.TokenRevocationStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
RefreshTokenLifespan: config.GetRefreshTokenLifespan(),
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | [
"func",
"OAuth2RefreshTokenGrantFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"RefreshTokenGrantHandler",
"{",
"AccessTokenStr... | // OAuth2RefreshTokenGrantFactory creates an OAuth2 refresh grant handler and registers
// an access token, refresh token and authorize code validator. | [
"OAuth2RefreshTokenGrantFactory",
"creates",
"an",
"OAuth2",
"refresh",
"grant",
"handler",
"and",
"registers",
"an",
"access",
"token",
"refresh",
"token",
"and",
"authorize",
"code",
"validator",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L62-L72 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2ResourceOwnerPasswordCredentialsFactory | func OAuth2ResourceOwnerPasswordCredentialsFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.ResourceOwnerPasswordCredentialsGrantHandler{
ResourceOwnerPasswordCredentialsGrantStorage: storage.(oauth2.ResourceOwnerPasswordCredentialsGrantStorage),
HandleHelper: &oauth2.HandleHelper{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
AccessTokenStorage: storage.(oauth2.AccessTokenStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
RefreshTokenLifespan: config.GetRefreshTokenLifespan(),
},
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | go | func OAuth2ResourceOwnerPasswordCredentialsFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.ResourceOwnerPasswordCredentialsGrantHandler{
ResourceOwnerPasswordCredentialsGrantStorage: storage.(oauth2.ResourceOwnerPasswordCredentialsGrantStorage),
HandleHelper: &oauth2.HandleHelper{
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
AccessTokenStorage: storage.(oauth2.AccessTokenStorage),
AccessTokenLifespan: config.GetAccessTokenLifespan(),
RefreshTokenLifespan: config.GetRefreshTokenLifespan(),
},
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
ScopeStrategy: config.GetScopeStrategy(),
AudienceMatchingStrategy: config.GetAudienceStrategy(),
}
} | [
"func",
"OAuth2ResourceOwnerPasswordCredentialsFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"ResourceOwnerPasswordCredentialsGran... | // OAuth2ResourceOwnerPasswordCredentialsFactory creates an OAuth2 resource owner password credentials grant handler and registers
// an access token, refresh token and authorize code validator. | [
"OAuth2ResourceOwnerPasswordCredentialsFactory",
"creates",
"an",
"OAuth2",
"resource",
"owner",
"password",
"credentials",
"grant",
"handler",
"and",
"registers",
"an",
"access",
"token",
"refresh",
"token",
"and",
"authorize",
"code",
"validator",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L88-L101 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2TokenRevocationFactory | func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.TokenRevocationHandler{
TokenRevocationStorage: storage.(oauth2.TokenRevocationStorage),
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
}
} | go | func OAuth2TokenRevocationFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.TokenRevocationHandler{
TokenRevocationStorage: storage.(oauth2.TokenRevocationStorage),
AccessTokenStrategy: strategy.(oauth2.AccessTokenStrategy),
RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
}
} | [
"func",
"OAuth2TokenRevocationFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"TokenRevocationHandler",
"{",
"TokenRevocationSto... | // OAuth2TokenRevocationFactory creates an OAuth2 token revocation handler. | [
"OAuth2TokenRevocationFactory",
"creates",
"an",
"OAuth2",
"token",
"revocation",
"handler",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L104-L110 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2TokenIntrospectionFactory | func OAuth2TokenIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.CoreValidator{
CoreStrategy: strategy.(oauth2.CoreStrategy),
CoreStorage: storage.(oauth2.CoreStorage),
ScopeStrategy: config.GetScopeStrategy(),
DisableRefreshTokenValidation: config.DisableRefreshTokenValidation,
}
} | go | func OAuth2TokenIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.CoreValidator{
CoreStrategy: strategy.(oauth2.CoreStrategy),
CoreStorage: storage.(oauth2.CoreStorage),
ScopeStrategy: config.GetScopeStrategy(),
DisableRefreshTokenValidation: config.DisableRefreshTokenValidation,
}
} | [
"func",
"OAuth2TokenIntrospectionFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"CoreValidator",
"{",
"CoreStrategy",
":",
... | // OAuth2TokenIntrospectionFactory creates an OAuth2 token introspection handler and registers
// an access token and refresh token validator. | [
"OAuth2TokenIntrospectionFactory",
"creates",
"an",
"OAuth2",
"token",
"introspection",
"handler",
"and",
"registers",
"an",
"access",
"token",
"and",
"refresh",
"token",
"validator",
"."
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L114-L121 | train |
ory/fosite | compose/compose_oauth2.go | OAuth2StatelessJWTIntrospectionFactory | func OAuth2StatelessJWTIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.StatelessJWTValidator{
JWTAccessTokenStrategy: strategy.(oauth2.JWTAccessTokenStrategy),
ScopeStrategy: config.GetScopeStrategy(),
}
} | go | func OAuth2StatelessJWTIntrospectionFactory(config *Config, storage interface{}, strategy interface{}) interface{} {
return &oauth2.StatelessJWTValidator{
JWTAccessTokenStrategy: strategy.(oauth2.JWTAccessTokenStrategy),
ScopeStrategy: config.GetScopeStrategy(),
}
} | [
"func",
"OAuth2StatelessJWTIntrospectionFactory",
"(",
"config",
"*",
"Config",
",",
"storage",
"interface",
"{",
"}",
",",
"strategy",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"return",
"&",
"oauth2",
".",
"StatelessJWTValidator",
"{",
"JWTAccess... | // OAuth2StatelessJWTIntrospectionFactory creates an OAuth2 token introspection handler and
// registers an access token validator. This can only be used to validate JWTs and does so
// statelessly, meaning it uses only the data available in the JWT itself, and does not access the
// storage implementation at all.
//
// Due to the stateless nature of this factory, THE BUILT-IN REVOCATION MECHANISMS WILL NOT WORK.
// If you need revocation, you can validate JWTs statefully, using the other factories. | [
"OAuth2StatelessJWTIntrospectionFactory",
"creates",
"an",
"OAuth2",
"token",
"introspection",
"handler",
"and",
"registers",
"an",
"access",
"token",
"validator",
".",
"This",
"can",
"only",
"be",
"used",
"to",
"validate",
"JWTs",
"and",
"does",
"so",
"statelessly"... | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/compose/compose_oauth2.go#L130-L135 | train |
ory/fosite | internal/oauth2_strategy.go | NewMockCoreStrategy | func NewMockCoreStrategy(ctrl *gomock.Controller) *MockCoreStrategy {
mock := &MockCoreStrategy{ctrl: ctrl}
mock.recorder = &MockCoreStrategyMockRecorder{mock}
return mock
} | go | func NewMockCoreStrategy(ctrl *gomock.Controller) *MockCoreStrategy {
mock := &MockCoreStrategy{ctrl: ctrl}
mock.recorder = &MockCoreStrategyMockRecorder{mock}
return mock
} | [
"func",
"NewMockCoreStrategy",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockCoreStrategy",
"{",
"mock",
":=",
"&",
"MockCoreStrategy",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockCoreStrategyMockRecorder",
"{",... | // NewMockCoreStrategy creates a new mock instance | [
"NewMockCoreStrategy",
"creates",
"a",
"new",
"mock",
"instance"
] | 27bbe0033273157ea449310c064675127e2550e6 | https://github.com/ory/fosite/blob/27bbe0033273157ea449310c064675127e2550e6/internal/oauth2_strategy.go#L28-L32 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.