id int32 0 167k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
13,900 | itsyouonline/identityserver | db/persistentlog/persistentlog.go | New | func New(key string, flow FlowType, message string) *PersistentLog {
return &PersistentLog{
Timestamp: time.Now(),
Flow: flow,
Key: key,
Message: message,
}
} | go | func New(key string, flow FlowType, message string) *PersistentLog {
return &PersistentLog{
Timestamp: time.Now(),
Flow: flow,
Key: key,
Message: message,
}
} | [
"func",
"New",
"(",
"key",
"string",
",",
"flow",
"FlowType",
",",
"message",
"string",
")",
"*",
"PersistentLog",
"{",
"return",
"&",
"PersistentLog",
"{",
"Timestamp",
":",
"time",
".",
"Now",
"(",
")",
",",
"Flow",
":",
"flow",
",",
"Key",
":",
"k... | // New creates a new PersistentLog | [
"New",
"creates",
"a",
"new",
"PersistentLog"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/persistentlog/persistentlog.go#L22-L29 |
13,901 | itsyouonline/identityserver | validation/email.go | RequestValidation | func (service *IYOEmailAddressValidationService) RequestValidation(request *http.Request, username string, email string, confirmationurl string, langKey string) (key string, err error) {
valMngr := validation.NewManager(request)
info, err := valMngr.NewEmailAddressValidationInformation(username, email)
if err != nil {
log.Error(err)
return
}
err = valMngr.SaveEmailAddressValidationInformation(info)
if err != nil {
log.Error(err)
return
}
translationValues := tools.TranslationValues{
"emailvalidation_title": nil,
"emailvalidation_text": struct{ Email string }{Email: email},
"emailvalidation_buttontext": nil,
"emailvalidation_reason": nil,
"emailvalidation_subject": nil,
"emailvalidation_urlcaption": nil,
}
translations, err := tools.ParseTranslations(langKey, translationValues)
if err != nil {
log.Error("Failed to parse translations: ", err)
return
}
validationurl := fmt.Sprintf("%s?c=%s&k=%s&l=%s", confirmationurl, url.QueryEscape(info.Secret), url.QueryEscape(info.Key), langKey)
templateParameters := EmailWithButtonTemplateParams{
UrlCaption: translations["emailvalidation_urlcaption"],
Url: validationurl,
Username: username,
Title: translations["emailvalidation_title"],
Text: translations["emailvalidation_text"],
ButtonText: translations["emailvalidation_buttontext"],
Reason: translations["emailvalidation_reason"],
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
go service.EmailService.Send([]string{email}, translations["emailvalidation_subject"], message)
key = info.Key
return
} | go | func (service *IYOEmailAddressValidationService) RequestValidation(request *http.Request, username string, email string, confirmationurl string, langKey string) (key string, err error) {
valMngr := validation.NewManager(request)
info, err := valMngr.NewEmailAddressValidationInformation(username, email)
if err != nil {
log.Error(err)
return
}
err = valMngr.SaveEmailAddressValidationInformation(info)
if err != nil {
log.Error(err)
return
}
translationValues := tools.TranslationValues{
"emailvalidation_title": nil,
"emailvalidation_text": struct{ Email string }{Email: email},
"emailvalidation_buttontext": nil,
"emailvalidation_reason": nil,
"emailvalidation_subject": nil,
"emailvalidation_urlcaption": nil,
}
translations, err := tools.ParseTranslations(langKey, translationValues)
if err != nil {
log.Error("Failed to parse translations: ", err)
return
}
validationurl := fmt.Sprintf("%s?c=%s&k=%s&l=%s", confirmationurl, url.QueryEscape(info.Secret), url.QueryEscape(info.Key), langKey)
templateParameters := EmailWithButtonTemplateParams{
UrlCaption: translations["emailvalidation_urlcaption"],
Url: validationurl,
Username: username,
Title: translations["emailvalidation_title"],
Text: translations["emailvalidation_text"],
ButtonText: translations["emailvalidation_buttontext"],
Reason: translations["emailvalidation_reason"],
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
go service.EmailService.Send([]string{email}, translations["emailvalidation_subject"], message)
key = info.Key
return
} | [
"func",
"(",
"service",
"*",
"IYOEmailAddressValidationService",
")",
"RequestValidation",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"username",
"string",
",",
"email",
"string",
",",
"confirmationurl",
"string",
",",
"langKey",
"string",
")",
"(",
"key"... | //RequestValidation validates the email address by sending an email | [
"RequestValidation",
"validates",
"the",
"email",
"address",
"by",
"sending",
"an",
"email"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/validation/email.go#L41-L88 |
13,902 | itsyouonline/identityserver | validation/email.go | RequestPasswordReset | func (service *IYOEmailAddressValidationService) RequestPasswordReset(request *http.Request, username string, emails []string, langKey string) (key string, err error) {
pwdMngr := password.NewManager(request)
token, err := pwdMngr.NewResetToken(username)
if err != nil {
return
}
if err = pwdMngr.SaveResetToken(token); err != nil {
return
}
translationValues := tools.TranslationValues{
"passwordreset_title": nil,
"passwordreset_text": nil,
"passwordreset_buttontext": nil,
"passwordreset_reason": nil,
"passwordreset_subject": nil,
"passwordreset_urlcaption": nil,
}
translations, err := tools.ParseTranslations(langKey, translationValues)
if err != nil {
log.Error("Failed to parse translations: ", err)
return
}
passwordreseturl := fmt.Sprintf("https://%s/login?lang=%s#/resetpassword/%s", request.Host, langKey, url.QueryEscape(token.Token))
templateParameters := EmailWithButtonTemplateParams{
UrlCaption: translations["passwordreset_urlcaption"],
Url: passwordreseturl,
Username: username,
Title: translations["passwordreset_title"],
Text: translations["passwordreset_text"],
ButtonText: translations["passwordreset_buttontext"],
Reason: translations["passwordreset_reason"],
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
go service.EmailService.Send(emails, translations["passwordreset_subject"], message)
key = token.Token
return
} | go | func (service *IYOEmailAddressValidationService) RequestPasswordReset(request *http.Request, username string, emails []string, langKey string) (key string, err error) {
pwdMngr := password.NewManager(request)
token, err := pwdMngr.NewResetToken(username)
if err != nil {
return
}
if err = pwdMngr.SaveResetToken(token); err != nil {
return
}
translationValues := tools.TranslationValues{
"passwordreset_title": nil,
"passwordreset_text": nil,
"passwordreset_buttontext": nil,
"passwordreset_reason": nil,
"passwordreset_subject": nil,
"passwordreset_urlcaption": nil,
}
translations, err := tools.ParseTranslations(langKey, translationValues)
if err != nil {
log.Error("Failed to parse translations: ", err)
return
}
passwordreseturl := fmt.Sprintf("https://%s/login?lang=%s#/resetpassword/%s", request.Host, langKey, url.QueryEscape(token.Token))
templateParameters := EmailWithButtonTemplateParams{
UrlCaption: translations["passwordreset_urlcaption"],
Url: passwordreseturl,
Username: username,
Title: translations["passwordreset_title"],
Text: translations["passwordreset_text"],
ButtonText: translations["passwordreset_buttontext"],
Reason: translations["passwordreset_reason"],
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
go service.EmailService.Send(emails, translations["passwordreset_subject"], message)
key = token.Token
return
} | [
"func",
"(",
"service",
"*",
"IYOEmailAddressValidationService",
")",
"RequestPasswordReset",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"username",
"string",
",",
"emails",
"[",
"]",
"string",
",",
"langKey",
"string",
")",
"(",
"key",
"string",
",",
... | //RequestPasswordReset Request a password reset | [
"RequestPasswordReset",
"Request",
"a",
"password",
"reset"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/validation/email.go#L91-L134 |
13,903 | itsyouonline/identityserver | validation/email.go | SendOrganizationInviteEmail | func (service *IYOEmailAddressValidationService) SendOrganizationInviteEmail(request *http.Request, invite *invitations.JoinOrganizationInvitation) (err error) {
InviteURL := fmt.Sprintf(invitations.InviteURL, request.Host, url.QueryEscape(invite.Code))
templateParameters := EmailWithButtonTemplateParams{
Url: InviteURL,
Username: invite.EmailAddress,
Title: "It's You Online organization invitation",
Text: fmt.Sprintf("You have been invited to the %s organization on It's You Online. Click the button below to accept the invitation.", invite.Organization),
ButtonText: "Accept invitation",
Reason: "You’re receiving this email because someone invited you to an organization at ItsYou.Online. If you think this was a mistake please ignore this email.",
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
subject := fmt.Sprintf("You have been invited to the %s organization", invite.Organization)
recipients := []string{invite.EmailAddress}
go service.EmailService.Send(recipients, subject, message)
return
} | go | func (service *IYOEmailAddressValidationService) SendOrganizationInviteEmail(request *http.Request, invite *invitations.JoinOrganizationInvitation) (err error) {
InviteURL := fmt.Sprintf(invitations.InviteURL, request.Host, url.QueryEscape(invite.Code))
templateParameters := EmailWithButtonTemplateParams{
Url: InviteURL,
Username: invite.EmailAddress,
Title: "It's You Online organization invitation",
Text: fmt.Sprintf("You have been invited to the %s organization on It's You Online. Click the button below to accept the invitation.", invite.Organization),
ButtonText: "Accept invitation",
Reason: "You’re receiving this email because someone invited you to an organization at ItsYou.Online. If you think this was a mistake please ignore this email.",
LogoUrl: fmt.Sprintf("https://%s/assets/img/its-you-online.png", request.Host),
}
message, err := tools.RenderTemplate(emailWithButtonTemplateName, templateParameters)
if err != nil {
return
}
subject := fmt.Sprintf("You have been invited to the %s organization", invite.Organization)
recipients := []string{invite.EmailAddress}
go service.EmailService.Send(recipients, subject, message)
return
} | [
"func",
"(",
"service",
"*",
"IYOEmailAddressValidationService",
")",
"SendOrganizationInviteEmail",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"invite",
"*",
"invitations",
".",
"JoinOrganizationInvitation",
")",
"(",
"err",
"error",
")",
"{",
"InviteURL",
... | //SendOrganizationInviteEmail Sends an organization invite email | [
"SendOrganizationInviteEmail",
"Sends",
"an",
"organization",
"invite",
"email"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/validation/email.go#L137-L156 |
13,904 | itsyouonline/identityserver | validation/email.go | ConfirmRegistrationValidation | func (service *IYOEmailAddressValidationService) ConfirmRegistrationValidation(r *http.Request, key, secret string) (err error) {
info, err := service.getEmailAddressValidationInformation(r, key)
if err != nil {
return
}
if info == nil {
err = ErrInvalidOrExpiredKey
return
}
if info.Secret != secret {
err = ErrInvalidCode
return
}
return validation.NewManager(r).UpdateEmailAddressValidationInformation(key, true)
} | go | func (service *IYOEmailAddressValidationService) ConfirmRegistrationValidation(r *http.Request, key, secret string) (err error) {
info, err := service.getEmailAddressValidationInformation(r, key)
if err != nil {
return
}
if info == nil {
err = ErrInvalidOrExpiredKey
return
}
if info.Secret != secret {
err = ErrInvalidCode
return
}
return validation.NewManager(r).UpdateEmailAddressValidationInformation(key, true)
} | [
"func",
"(",
"service",
"*",
"IYOEmailAddressValidationService",
")",
"ConfirmRegistrationValidation",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"key",
",",
"secret",
"string",
")",
"(",
"err",
"error",
")",
"{",
"info",
",",
"err",
":=",
"service",
".",
... | // ConfirmRegistrationValidation checks if the supplied code matches the username and key. It does not add an entry
// in the validated email addresses collection | [
"ConfirmRegistrationValidation",
"checks",
"if",
"the",
"supplied",
"code",
"matches",
"the",
"username",
"and",
"key",
".",
"It",
"does",
"not",
"add",
"an",
"entry",
"in",
"the",
"validated",
"email",
"addresses",
"collection"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/validation/email.go#L220-L234 |
13,905 | itsyouonline/identityserver | oauthservice/client.go | NewOauth2Client | func NewOauth2Client(clientID, label, callbackURL string, clientCredentialsGrantType bool) *Oauth2Client {
c := &Oauth2Client{
ClientID: clientID,
Label: label,
CallbackURL: callbackURL,
ClientCredentialsGrantType: clientCredentialsGrantType,
}
randombytes := make([]byte, 39) //Multiple of 3 to make sure no padding is added
rand.Read(randombytes)
c.Secret = base64.URLEncoding.EncodeToString(randombytes)
return c
} | go | func NewOauth2Client(clientID, label, callbackURL string, clientCredentialsGrantType bool) *Oauth2Client {
c := &Oauth2Client{
ClientID: clientID,
Label: label,
CallbackURL: callbackURL,
ClientCredentialsGrantType: clientCredentialsGrantType,
}
randombytes := make([]byte, 39) //Multiple of 3 to make sure no padding is added
rand.Read(randombytes)
c.Secret = base64.URLEncoding.EncodeToString(randombytes)
return c
} | [
"func",
"NewOauth2Client",
"(",
"clientID",
",",
"label",
",",
"callbackURL",
"string",
",",
"clientCredentialsGrantType",
"bool",
")",
"*",
"Oauth2Client",
"{",
"c",
":=",
"&",
"Oauth2Client",
"{",
"ClientID",
":",
"clientID",
",",
"Label",
":",
"label",
",",... | //NewOauth2Client creates a new NewOauth2Client with a random secret | [
"NewOauth2Client",
"creates",
"a",
"new",
"NewOauth2Client",
"with",
"a",
"random",
"secret"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/client.go#L18-L30 |
13,906 | itsyouonline/identityserver | db/user/Phonenumber.go | Validate | func (p Phonenumber) Validate() bool {
return validator.Validate(p) == nil &&
regexp.MustCompile(`^[a-zA-Z\d\-_\s]{2,50}$`).MatchString(p.Label) &&
regexp.MustCompile(`\+[0-9]{6,50}`).MatchString(p.Phonenumber)
} | go | func (p Phonenumber) Validate() bool {
return validator.Validate(p) == nil &&
regexp.MustCompile(`^[a-zA-Z\d\-_\s]{2,50}$`).MatchString(p.Label) &&
regexp.MustCompile(`\+[0-9]{6,50}`).MatchString(p.Phonenumber)
} | [
"func",
"(",
"p",
"Phonenumber",
")",
"Validate",
"(",
")",
"bool",
"{",
"return",
"validator",
".",
"Validate",
"(",
"p",
")",
"==",
"nil",
"&&",
"regexp",
".",
"MustCompile",
"(",
"`^[a-zA-Z\\d\\-_\\s]{2,50}$`",
")",
".",
"MatchString",
"(",
"p",
".",
... | //Validate checks if a phone number is in a valid format | [
"Validate",
"checks",
"if",
"a",
"phone",
"number",
"is",
"in",
"a",
"valid",
"format"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Phonenumber.go#L15-L19 |
13,907 | itsyouonline/identityserver | db/contract/db.go | Exists | func (m *Manager) Exists(contractID string) (bool, error) {
count, err := m.collection.Find(bson.M{"contractid": contractID}).Count()
return count >= 1, err
} | go | func (m *Manager) Exists(contractID string) (bool, error) {
count, err := m.collection.Find(bson.M{"contractid": contractID}).Count()
return count >= 1, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Exists",
"(",
"contractID",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"m",
".",
"collection",
".",
"Find",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"contractID",
"}"... | //Exists checks if a contract with this contractId already exists. | [
"Exists",
"checks",
"if",
"a",
"contract",
"with",
"this",
"contractId",
"already",
"exists",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/contract/db.go#L60-L63 |
13,908 | itsyouonline/identityserver | db/contract/db.go | AddSignature | func (m *Manager) AddSignature(contractID string, signature Signature) (err error) {
err = m.collection.Update(bson.M{"contractid": contractID}, bson.M{"$push": bson.M{"signatures": signature}})
return
} | go | func (m *Manager) AddSignature(contractID string, signature Signature) (err error) {
err = m.collection.Update(bson.M{"contractid": contractID}, bson.M{"$push": bson.M{"signatures": signature}})
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AddSignature",
"(",
"contractID",
"string",
",",
"signature",
"Signature",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"m",
".",
"collection",
".",
"Update",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"... | //AddSignature adds a signature to a contract | [
"AddSignature",
"adds",
"a",
"signature",
"to",
"a",
"contract"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/contract/db.go#L66-L69 |
13,909 | itsyouonline/identityserver | db/contract/db.go | IsParticipant | func (m *Manager) IsParticipant(contractID string, name string) (isparticipant bool, err error) {
count, err := m.collection.Find(bson.M{"contractid": contractID, "parties.name": name}).Count()
if err != nil {
return
}
isparticipant = count != 0
return
} | go | func (m *Manager) IsParticipant(contractID string, name string) (isparticipant bool, err error) {
count, err := m.collection.Find(bson.M{"contractid": contractID, "parties.name": name}).Count()
if err != nil {
return
}
isparticipant = count != 0
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"IsParticipant",
"(",
"contractID",
"string",
",",
"name",
"string",
")",
"(",
"isparticipant",
"bool",
",",
"err",
"error",
")",
"{",
"count",
",",
"err",
":=",
"m",
".",
"collection",
".",
"Find",
"(",
"bson",
... | //IsParticipant check if name is participant in contract with id contractID | [
"IsParticipant",
"check",
"if",
"name",
"is",
"participant",
"in",
"contract",
"with",
"id",
"contractID"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/contract/db.go#L85-L93 |
13,910 | itsyouonline/identityserver | db/contract/db.go | GetByIncludedParty | func (m *Manager) GetByIncludedParty(party *Party, start int, max int, includeExpired bool) (contracts []Contract, err error) {
contracts = make([]Contract, 0)
query := bson.M{"parties.type": party.Type, "parties.name": party.Name}
if !includeExpired {
query["$and"] = []bson.M{bson.M{"expires": bson.M{"$gte": time.Now()}}, bson.M{"expired": nil}}
}
err = m.collection.Find(query).Skip(start).Limit(max).All(&contracts)
if err == mgo.ErrNotFound {
err = nil
}
return
} | go | func (m *Manager) GetByIncludedParty(party *Party, start int, max int, includeExpired bool) (contracts []Contract, err error) {
contracts = make([]Contract, 0)
query := bson.M{"parties.type": party.Type, "parties.name": party.Name}
if !includeExpired {
query["$and"] = []bson.M{bson.M{"expires": bson.M{"$gte": time.Now()}}, bson.M{"expired": nil}}
}
err = m.collection.Find(query).Skip(start).Limit(max).All(&contracts)
if err == mgo.ErrNotFound {
err = nil
}
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetByIncludedParty",
"(",
"party",
"*",
"Party",
",",
"start",
"int",
",",
"max",
"int",
",",
"includeExpired",
"bool",
")",
"(",
"contracts",
"[",
"]",
"Contract",
",",
"err",
"error",
")",
"{",
"contracts",
"="... | //GetByIncludedParty Get contracts that include the included party | [
"GetByIncludedParty",
"Get",
"contracts",
"that",
"include",
"the",
"included",
"party"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/contract/db.go#L96-L107 |
13,911 | itsyouonline/identityserver | db/user/apikey/db.go | Exists | func (m *Manager) Exists(username string, applicationid string) (bool, error) {
count, err := m.getCollection().Find(bson.M{"username": username, "applicationid": applicationid}).Count()
return count == 1, err
} | go | func (m *Manager) Exists(username string, applicationid string) (bool, error) {
count, err := m.getCollection().Find(bson.M{"username": username, "applicationid": applicationid}).Count()
return count == 1, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Exists",
"(",
"username",
"string",
",",
"applicationid",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"m",
".",
"getCollection",
"(",
")",
".",
"Find",
"(",
"bson",
".",
"M"... | // Exists checks if an api key for a user exists | [
"Exists",
"checks",
"if",
"an",
"api",
"key",
"for",
"a",
"user",
"exists"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/apikey/db.go#L57-L61 |
13,912 | itsyouonline/identityserver | identityservice/contract/oauth2_oauth_2_0_middleware.go | newOauth2oauth_2_0Middleware | func newOauth2oauth_2_0Middleware(scopes []string) *Oauth2oauth_2_0Middleware {
om := Oauth2oauth_2_0Middleware{}
om.Scopes = scopes
return &om
} | go | func newOauth2oauth_2_0Middleware(scopes []string) *Oauth2oauth_2_0Middleware {
om := Oauth2oauth_2_0Middleware{}
om.Scopes = scopes
return &om
} | [
"func",
"newOauth2oauth_2_0Middleware",
"(",
"scopes",
"[",
"]",
"string",
")",
"*",
"Oauth2oauth_2_0Middleware",
"{",
"om",
":=",
"Oauth2oauth_2_0Middleware",
"{",
"}",
"\n",
"om",
".",
"Scopes",
"=",
"scopes",
"\n\n",
"return",
"&",
"om",
"\n",
"}"
] | // newOauth2oauth_2_0Middlewarecreate new Oauth2oauth_2_0Middleware struct | [
"newOauth2oauth_2_0Middlewarecreate",
"new",
"Oauth2oauth_2_0Middleware",
"struct"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/contract/oauth2_oauth_2_0_middleware.go#L19-L24 |
13,913 | itsyouonline/identityserver | identityservice/contract/oauth2_oauth_2_0_middleware.go | CheckScopes | func (om *Oauth2oauth_2_0Middleware) CheckScopes(scopes []string) bool {
if len(om.Scopes) == 0 {
return true
}
for _, allowed := range om.Scopes {
for _, scope := range scopes {
if scope == allowed {
return true
}
}
}
return false
} | go | func (om *Oauth2oauth_2_0Middleware) CheckScopes(scopes []string) bool {
if len(om.Scopes) == 0 {
return true
}
for _, allowed := range om.Scopes {
for _, scope := range scopes {
if scope == allowed {
return true
}
}
}
return false
} | [
"func",
"(",
"om",
"*",
"Oauth2oauth_2_0Middleware",
")",
"CheckScopes",
"(",
"scopes",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"om",
".",
"Scopes",
")",
"==",
"0",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"allowed",... | // CheckScopes checks whether user has needed scopes | [
"CheckScopes",
"checks",
"whether",
"user",
"has",
"needed",
"scopes"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/contract/oauth2_oauth_2_0_middleware.go#L27-L40 |
13,914 | itsyouonline/identityserver | credentials/password/db.go | InitModels | func InitModels() {
index := mgo.Index{
Key: []string{"username"},
Unique: true,
DropDups: true,
}
db.EnsureIndex(mongoCollectionName, index)
index = mgo.Index{
Key: []string{"username", "token"},
Unique: true,
DropDups: true,
}
db.EnsureIndex(mongoCollectionNameResetToken, index)
automaticExpiration := mgo.Index{
Key: []string{"createdat"},
ExpireAfter: time.Minute * 10,
Background: true,
}
db.EnsureIndex(mongoCollectionNameResetToken, automaticExpiration)
} | go | func InitModels() {
index := mgo.Index{
Key: []string{"username"},
Unique: true,
DropDups: true,
}
db.EnsureIndex(mongoCollectionName, index)
index = mgo.Index{
Key: []string{"username", "token"},
Unique: true,
DropDups: true,
}
db.EnsureIndex(mongoCollectionNameResetToken, index)
automaticExpiration := mgo.Index{
Key: []string{"createdat"},
ExpireAfter: time.Minute * 10,
Background: true,
}
db.EnsureIndex(mongoCollectionNameResetToken, automaticExpiration)
} | [
"func",
"InitModels",
"(",
")",
"{",
"index",
":=",
"mgo",
".",
"Index",
"{",
"Key",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"Unique",
":",
"true",
",",
"DropDups",
":",
"true",
",",
"}",
"\n",
"db",
".",
"EnsureIndex",
"(",
"mongoCol... | //InitModels initializes models in mongo, if required. | [
"InitModels",
"initializes",
"models",
"in",
"mongo",
"if",
"required",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L41-L62 |
13,915 | itsyouonline/identityserver | credentials/password/db.go | Validate | func (pwm *Manager) Validate(username, password string) (bool, error) {
var storedPassword userPass
if err := pwm.collection.Find(bson.M{"username": username}).One(&storedPassword); err != nil {
if err == mgo.ErrNotFound {
log.Debug("No password found for this user")
return false, nil
}
log.Debug(err)
return false, err
}
match := keyderivation.Check(password, storedPassword.Password)
return match, nil
} | go | func (pwm *Manager) Validate(username, password string) (bool, error) {
var storedPassword userPass
if err := pwm.collection.Find(bson.M{"username": username}).One(&storedPassword); err != nil {
if err == mgo.ErrNotFound {
log.Debug("No password found for this user")
return false, nil
}
log.Debug(err)
return false, err
}
match := keyderivation.Check(password, storedPassword.Password)
return match, nil
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"Validate",
"(",
"username",
",",
"password",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"storedPassword",
"userPass",
"\n",
"if",
"err",
":=",
"pwm",
".",
"collection",
".",
"Find",
"(",
"bson",... | //Validate checks the password for a specific username | [
"Validate",
"checks",
"the",
"password",
"for",
"a",
"specific",
"username"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L90-L102 |
13,916 | itsyouonline/identityserver | credentials/password/db.go | Save | func (pwm *Manager) Save(username, password string) error {
//TODO: username and password validation
passwordHash, err := keyderivation.Hash(password)
if err != nil {
log.Error("ERROR hashing password")
log.Debug("ERROR hashing password: ", err)
return errors.New("internal_error")
}
if len(password) < passwordMinLength {
return errors.New("invalid_password")
}
storedPassword := userPass{Username: username, Password: passwordHash}
_, err = pwm.collection.Upsert(bson.M{"username": username}, storedPassword)
return err
} | go | func (pwm *Manager) Save(username, password string) error {
//TODO: username and password validation
passwordHash, err := keyderivation.Hash(password)
if err != nil {
log.Error("ERROR hashing password")
log.Debug("ERROR hashing password: ", err)
return errors.New("internal_error")
}
if len(password) < passwordMinLength {
return errors.New("invalid_password")
}
storedPassword := userPass{Username: username, Password: passwordHash}
_, err = pwm.collection.Upsert(bson.M{"username": username}, storedPassword)
return err
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"Save",
"(",
"username",
",",
"password",
"string",
")",
"error",
"{",
"//TODO: username and password validation",
"passwordHash",
",",
"err",
":=",
"keyderivation",
".",
"Hash",
"(",
"password",
")",
"\n",
"if",
"err",... | // Save stores a password for a specific username. | [
"Save",
"stores",
"a",
"password",
"for",
"a",
"specific",
"username",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L105-L121 |
13,917 | itsyouonline/identityserver | credentials/password/db.go | Check | func Check(password string) error {
if len(password) < passwordMinLength {
return ErrInvalidPassword
}
_, err := keyderivation.Hash(password)
if err != nil {
log.Debug("Failed to hash password: ", err)
return err
}
return nil
} | go | func Check(password string) error {
if len(password) < passwordMinLength {
return ErrInvalidPassword
}
_, err := keyderivation.Hash(password)
if err != nil {
log.Debug("Failed to hash password: ", err)
return err
}
return nil
} | [
"func",
"Check",
"(",
"password",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"password",
")",
"<",
"passwordMinLength",
"{",
"return",
"ErrInvalidPassword",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"keyderivation",
".",
"Hash",
"(",
"password",
")",
"... | // Check to see if a password is valid for a user. | [
"Check",
"to",
"see",
"if",
"a",
"password",
"is",
"valid",
"for",
"a",
"user",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L124-L134 |
13,918 | itsyouonline/identityserver | credentials/password/db.go | NewResetToken | func (pwm *Manager) NewResetToken(username string) (token *ResetToken, err error) {
tokenstring, err := tools.GenerateRandomString()
if err != nil {
return
}
token = &ResetToken{Token: tokenstring, CreatedAt: time.Now(), Username: username}
return
} | go | func (pwm *Manager) NewResetToken(username string) (token *ResetToken, err error) {
tokenstring, err := tools.GenerateRandomString()
if err != nil {
return
}
token = &ResetToken{Token: tokenstring, CreatedAt: time.Now(), Username: username}
return
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"NewResetToken",
"(",
"username",
"string",
")",
"(",
"token",
"*",
"ResetToken",
",",
"err",
"error",
")",
"{",
"tokenstring",
",",
"err",
":=",
"tools",
".",
"GenerateRandomString",
"(",
")",
"\n",
"if",
"err",
... | // NewResetToken get new reset token | [
"NewResetToken",
"get",
"new",
"reset",
"token"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L137-L144 |
13,919 | itsyouonline/identityserver | credentials/password/db.go | SaveResetToken | func (pwm *Manager) SaveResetToken(token *ResetToken) (err error) {
err = pwm.tokencollection.Insert(token)
return
} | go | func (pwm *Manager) SaveResetToken(token *ResetToken) (err error) {
err = pwm.tokencollection.Insert(token)
return
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"SaveResetToken",
"(",
"token",
"*",
"ResetToken",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"pwm",
".",
"tokencollection",
".",
"Insert",
"(",
"token",
")",
"\n",
"return",
"\n",
"}"
] | // SaveResetToken save reset token | [
"SaveResetToken",
"save",
"reset",
"token"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L147-L150 |
13,920 | itsyouonline/identityserver | credentials/password/db.go | FindResetToken | func (pwm *Manager) FindResetToken(token string) (tokenobj *ResetToken, err error) {
tokenobj = &ResetToken{}
err = pwm.tokencollection.Find(bson.M{"token": token}).One(tokenobj)
return
} | go | func (pwm *Manager) FindResetToken(token string) (tokenobj *ResetToken, err error) {
tokenobj = &ResetToken{}
err = pwm.tokencollection.Find(bson.M{"token": token}).One(tokenobj)
return
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"FindResetToken",
"(",
"token",
"string",
")",
"(",
"tokenobj",
"*",
"ResetToken",
",",
"err",
"error",
")",
"{",
"tokenobj",
"=",
"&",
"ResetToken",
"{",
"}",
"\n",
"err",
"=",
"pwm",
".",
"tokencollection",
".... | // FindResetToken find reset token by token | [
"FindResetToken",
"find",
"reset",
"token",
"by",
"token"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L153-L157 |
13,921 | itsyouonline/identityserver | credentials/password/db.go | DeleteResetToken | func (pwm *Manager) DeleteResetToken(token string) (err error) {
_, err = pwm.tokencollection.RemoveAll(bson.M{"token": token})
return
} | go | func (pwm *Manager) DeleteResetToken(token string) (err error) {
_, err = pwm.tokencollection.RemoveAll(bson.M{"token": token})
return
} | [
"func",
"(",
"pwm",
"*",
"Manager",
")",
"DeleteResetToken",
"(",
"token",
"string",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"pwm",
".",
"tokencollection",
".",
"RemoveAll",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"token",
"}... | // DeleteResetToken delete reset token by token | [
"DeleteResetToken",
"delete",
"reset",
"token",
"by",
"token"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/db.go#L160-L163 |
13,922 | itsyouonline/identityserver | siteservice/authorize.go | ShowAuthorizeForm | func (service *Service) ShowAuthorizeForm(w http.ResponseWriter, r *http.Request) {
redirectURI := "#" + r.RequestURI
parameters := make(url.Values)
redirectURI += parameters.Encode()
http.Redirect(w, r, redirectURI, http.StatusFound)
} | go | func (service *Service) ShowAuthorizeForm(w http.ResponseWriter, r *http.Request) {
redirectURI := "#" + r.RequestURI
parameters := make(url.Values)
redirectURI += parameters.Encode()
http.Redirect(w, r, redirectURI, http.StatusFound)
} | [
"func",
"(",
"service",
"*",
"Service",
")",
"ShowAuthorizeForm",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"redirectURI",
":=",
"\"",
"\"",
"+",
"r",
".",
"RequestURI",
"\n",
"parameters",
":=",
"make",
... | //ShowAuthorizeForm shows the scopes an application requested and asks a user for confirmation | [
"ShowAuthorizeForm",
"shows",
"the",
"scopes",
"an",
"application",
"requested",
"and",
"asks",
"a",
"user",
"for",
"confirmation"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/siteservice/authorize.go#L9-L14 |
13,923 | itsyouonline/identityserver | identityservice/invitations/db.go | NewInvitationManager | func NewInvitationManager(r *http.Request) *InvitationManager {
session := db.GetDBSession(r)
return &InvitationManager{
session: session,
collection: getOrganizationRequestCollection(session),
}
} | go | func NewInvitationManager(r *http.Request) *InvitationManager {
session := db.GetDBSession(r)
return &InvitationManager{
session: session,
collection: getOrganizationRequestCollection(session),
}
} | [
"func",
"NewInvitationManager",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"*",
"InvitationManager",
"{",
"session",
":=",
"db",
".",
"GetDBSession",
"(",
"r",
")",
"\n",
"return",
"&",
"InvitationManager",
"{",
"session",
":",
"session",
",",
"collection",... | //NewInvitationManager creates and initializes a new InvitationManager | [
"NewInvitationManager",
"creates",
"and",
"initializes",
"a",
"new",
"InvitationManager"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L27-L33 |
13,924 | itsyouonline/identityserver | identityservice/invitations/db.go | GetByUser | func (o *InvitationManager) GetByUser(username string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"user": username}).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) GetByUser(username string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"user": username}).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetByUser",
"(",
"username",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
"\n",
"err",
":=",
"o",
... | // GetByUser gets all invitations for a user. | [
"GetByUser",
"gets",
"all",
"invitations",
"for",
"a",
"user",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L36-L40 |
13,925 | itsyouonline/identityserver | identityservice/invitations/db.go | GetByEmail | func (o *InvitationManager) GetByEmail(email string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"emailaddress": email}).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) GetByEmail(email string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"emailaddress": email}).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetByEmail",
"(",
"email",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
"\n",
"err",
":=",
"o",
... | // GetByEmail gets all invitations for an email address. | [
"GetByEmail",
"gets",
"all",
"invitations",
"for",
"an",
"email",
"address",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L43-L47 |
13,926 | itsyouonline/identityserver | identityservice/invitations/db.go | GetByPhonenumber | func (o *InvitationManager) GetByPhonenumber(phonenumber string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"phonenumber": phonenumber}).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) GetByPhonenumber(phonenumber string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"phonenumber": phonenumber}).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetByPhonenumber",
"(",
"phonenumber",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
"\n",
"err",
":=... | // GetByPhonenumber gets all invitations for a phone number. | [
"GetByPhonenumber",
"gets",
"all",
"invitations",
"for",
"a",
"phone",
"number",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L50-L54 |
13,927 | itsyouonline/identityserver | identityservice/invitations/db.go | FilterByUser | func (o *InvitationManager) FilterByUser(username string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByUser(username)
}
qry := bson.M{
"user": username,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) FilterByUser(username string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByUser(username)
}
qry := bson.M{
"user": username,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"FilterByUser",
"(",
"username",
"string",
",",
"status",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}"... | // FilterByUser gets all invitations for a user, filtered on status | [
"FilterByUser",
"gets",
"all",
"invitations",
"for",
"a",
"user",
"filtered",
"on",
"status"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L57-L68 |
13,928 | itsyouonline/identityserver | identityservice/invitations/db.go | FilterByEmail | func (o *InvitationManager) FilterByEmail(email string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByEmail(email)
}
qry := bson.M{
"emailaddress": email,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) FilterByEmail(email string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByEmail(email)
}
qry := bson.M{
"emailaddress": email,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"FilterByEmail",
"(",
"email",
"string",
",",
"status",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
... | // FilterByEmail gets all invitations for an email address, filtered on status | [
"FilterByEmail",
"gets",
"all",
"invitations",
"for",
"an",
"email",
"address",
"filtered",
"on",
"status"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L71-L82 |
13,929 | itsyouonline/identityserver | identityservice/invitations/db.go | FilterByPhonenumber | func (o *InvitationManager) FilterByPhonenumber(phonenumber string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByPhonenumber(phonenumber)
}
qry := bson.M{
"phonenumber": phonenumber,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) FilterByPhonenumber(phonenumber string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByPhonenumber(phonenumber)
}
qry := bson.M{
"phonenumber": phonenumber,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"FilterByPhonenumber",
"(",
"phonenumber",
"string",
",",
"status",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
... | // FilterByPhonenumber gets all invitations for a phone number, filtered on status | [
"FilterByPhonenumber",
"gets",
"all",
"invitations",
"for",
"a",
"phone",
"number",
"filtered",
"on",
"status"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L85-L96 |
13,930 | itsyouonline/identityserver | identityservice/invitations/db.go | GetByOrganization | func (o *InvitationManager) GetByOrganization(globalid string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"organization": globalid}).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) GetByOrganization(globalid string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
err := o.collection.Find(bson.M{"organization": globalid}).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetByOrganization",
"(",
"globalid",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
"\n",
"err",
":=",... | // GetByOrganization gets all invitations for an organization | [
"GetByOrganization",
"gets",
"all",
"invitations",
"for",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L99-L103 |
13,931 | itsyouonline/identityserver | identityservice/invitations/db.go | FilterByOrganization | func (o *InvitationManager) FilterByOrganization(globalID string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByOrganization(globalID)
}
qry := bson.M{
"organization": globalID,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | go | func (o *InvitationManager) FilterByOrganization(globalID string, status string) ([]JoinOrganizationInvitation, error) {
orgRequests := []JoinOrganizationInvitation{}
if status == "" {
return o.GetByOrganization(globalID)
}
qry := bson.M{
"organization": globalID,
"status": status,
}
err := o.collection.Find(qry).All(&orgRequests)
return orgRequests, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"FilterByOrganization",
"(",
"globalID",
"string",
",",
"status",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"orgRequests",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{... | // FilterByOrganization gets all invitations for a user, filtered on status | [
"FilterByOrganization",
"gets",
"all",
"invitations",
"for",
"a",
"user",
"filtered",
"on",
"status"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L106-L117 |
13,932 | itsyouonline/identityserver | identityservice/invitations/db.go | RemoveAll | func (o *InvitationManager) RemoveAll(globalid string) error {
_, err := o.collection.RemoveAll(bson.M{"organization": globalid})
return err
} | go | func (o *InvitationManager) RemoveAll(globalid string) error {
_, err := o.collection.RemoveAll(bson.M{"organization": globalid})
return err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"RemoveAll",
"(",
"globalid",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"o",
".",
"collection",
".",
"RemoveAll",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"globalid",
"}",
")",
"\n",
"r... | // RemoveAll Removes all invitations linked to an organization | [
"RemoveAll",
"Removes",
"all",
"invitations",
"linked",
"to",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L192-L195 |
13,933 | itsyouonline/identityserver | identityservice/invitations/db.go | HasInvite | func (o *InvitationManager) HasInvite(globalid string, username string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "user": username}).Count()
return count != 0, err
} | go | func (o *InvitationManager) HasInvite(globalid string, username string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "user": username}).Count()
return count != 0, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"HasInvite",
"(",
"globalid",
"string",
",",
"username",
"string",
")",
"(",
"hasInvite",
"bool",
",",
"err",
"error",
")",
"{",
"count",
",",
"err",
":=",
"o",
".",
"collection",
".",
"Find",
"(",
"bson... | // HasInvite Checks if a user has an invite for an organization | [
"HasInvite",
"Checks",
"if",
"a",
"user",
"has",
"an",
"invite",
"for",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L198-L201 |
13,934 | itsyouonline/identityserver | identityservice/invitations/db.go | HasPhoneInvite | func (o *InvitationManager) HasPhoneInvite(globalid string, phonenumber string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "phonenumber": phonenumber}).Count()
return count != 0, err
} | go | func (o *InvitationManager) HasPhoneInvite(globalid string, phonenumber string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "phonenumber": phonenumber}).Count()
return count != 0, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"HasPhoneInvite",
"(",
"globalid",
"string",
",",
"phonenumber",
"string",
")",
"(",
"hasInvite",
"bool",
",",
"err",
"error",
")",
"{",
"count",
",",
"err",
":=",
"o",
".",
"collection",
".",
"Find",
"(",... | // HasPhoneInvite Checks if a phonenumber has an invite to an organization | [
"HasPhoneInvite",
"Checks",
"if",
"a",
"phonenumber",
"has",
"an",
"invite",
"to",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L204-L207 |
13,935 | itsyouonline/identityserver | identityservice/invitations/db.go | HasEmailInvite | func (o *InvitationManager) HasEmailInvite(globalid string, email string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "emailaddress": email}).Count()
return count != 0, err
} | go | func (o *InvitationManager) HasEmailInvite(globalid string, email string) (hasInvite bool, err error) {
count, err := o.collection.Find(bson.M{"organization": globalid, "emailaddress": email}).Count()
return count != 0, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"HasEmailInvite",
"(",
"globalid",
"string",
",",
"email",
"string",
")",
"(",
"hasInvite",
"bool",
",",
"err",
"error",
")",
"{",
"count",
",",
"err",
":=",
"o",
".",
"collection",
".",
"Find",
"(",
"bs... | // HasEmailInvite Checks if an emailaddress has an invite to an organization | [
"HasEmailInvite",
"Checks",
"if",
"an",
"emailaddress",
"has",
"an",
"invite",
"to",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L210-L213 |
13,936 | itsyouonline/identityserver | identityservice/invitations/db.go | CountByOrganization | func (o *InvitationManager) CountByOrganization(globalid string) (int, error) {
count, err := o.collection.Find(bson.M{"organization": globalid}).Count()
return count, err
} | go | func (o *InvitationManager) CountByOrganization(globalid string) (int, error) {
count, err := o.collection.Find(bson.M{"organization": globalid}).Count()
return count, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"CountByOrganization",
"(",
"globalid",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"o",
".",
"collection",
".",
"Find",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
... | // CountByOrganization Counts the amount of invitations, filtered by an organization | [
"CountByOrganization",
"Counts",
"the",
"amount",
"of",
"invitations",
"filtered",
"by",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L216-L219 |
13,937 | itsyouonline/identityserver | identityservice/invitations/db.go | GetByCode | func (o *InvitationManager) GetByCode(code string) (invite *JoinOrganizationInvitation, err error) {
qry := bson.M{
"code": code,
}
err = o.collection.Find(qry).One(&invite)
return
} | go | func (o *InvitationManager) GetByCode(code string) (invite *JoinOrganizationInvitation, err error) {
qry := bson.M{
"code": code,
}
err = o.collection.Find(qry).One(&invite)
return
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetByCode",
"(",
"code",
"string",
")",
"(",
"invite",
"*",
"JoinOrganizationInvitation",
",",
"err",
"error",
")",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"code",
",",
"}",
"\n",
"e... | // GetByCode Gets an invite by code | [
"GetByCode",
"Gets",
"an",
"invite",
"by",
"code"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L222-L228 |
13,938 | itsyouonline/identityserver | identityservice/invitations/db.go | SetAcceptedByCode | func (o *InvitationManager) SetAcceptedByCode(code string) error {
qry := bson.M{
"code": code,
}
update := bson.M{
"$set": bson.M{
"status": RequestAccepted,
},
}
return o.collection.Update(qry, update)
} | go | func (o *InvitationManager) SetAcceptedByCode(code string) error {
qry := bson.M{
"code": code,
}
update := bson.M{
"$set": bson.M{
"status": RequestAccepted,
},
}
return o.collection.Update(qry, update)
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"SetAcceptedByCode",
"(",
"code",
"string",
")",
"error",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"code",
",",
"}",
"\n",
"update",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"... | // SetAcceptedByCode Sets an invite as "accepted" | [
"SetAcceptedByCode",
"Sets",
"an",
"invite",
"as",
"accepted"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L231-L241 |
13,939 | itsyouonline/identityserver | identityservice/invitations/db.go | Remove | func (o *InvitationManager) Remove(globalID string, username string, searchString string) error {
qry := bson.M{
"organization": globalID,
"$or": []bson.M{
{"user": username},
{"emailaddress": searchString},
{"phonenumber": searchString},
},
}
return o.collection.Remove(qry)
} | go | func (o *InvitationManager) Remove(globalID string, username string, searchString string) error {
qry := bson.M{
"organization": globalID,
"$or": []bson.M{
{"user": username},
{"emailaddress": searchString},
{"phonenumber": searchString},
},
}
return o.collection.Remove(qry)
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"Remove",
"(",
"globalID",
"string",
",",
"username",
"string",
",",
"searchString",
"string",
")",
"error",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"globalID",
",",
"\"",
"\"",
":",
... | // Remove removes an invitation | [
"Remove",
"removes",
"an",
"invitation"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L244-L254 |
13,940 | itsyouonline/identityserver | identityservice/invitations/db.go | GetOpenOrganizationInvites | func (o *InvitationManager) GetOpenOrganizationInvites(globalID string) ([]JoinOrganizationInvitation, error) {
invites := []JoinOrganizationInvitation{}
qry := bson.M{
"user": globalID,
"status": "pending",
//"isorganization": true,
}
err := o.collection.Find(qry).All(&invites)
if err == mgo.ErrNotFound {
err = nil
}
return invites, err
} | go | func (o *InvitationManager) GetOpenOrganizationInvites(globalID string) ([]JoinOrganizationInvitation, error) {
invites := []JoinOrganizationInvitation{}
qry := bson.M{
"user": globalID,
"status": "pending",
//"isorganization": true,
}
err := o.collection.Find(qry).All(&invites)
if err == mgo.ErrNotFound {
err = nil
}
return invites, err
} | [
"func",
"(",
"o",
"*",
"InvitationManager",
")",
"GetOpenOrganizationInvites",
"(",
"globalID",
"string",
")",
"(",
"[",
"]",
"JoinOrganizationInvitation",
",",
"error",
")",
"{",
"invites",
":=",
"[",
"]",
"JoinOrganizationInvitation",
"{",
"}",
"\n",
"qry",
... | // GetInvites gets all invites where the organization is invited | [
"GetInvites",
"gets",
"all",
"invites",
"where",
"the",
"organization",
"is",
"invited"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/invitations/db.go#L257-L269 |
13,941 | itsyouonline/identityserver | db/user/db.go | Get | func (m *Manager) Get(id string) (*User, error) {
var user User
objectID := bson.ObjectIdHex(id)
if err := m.getUserCollection().FindId(objectID).One(&user); err != nil {
return nil, err
}
return &user, nil
} | go | func (m *Manager) Get(id string) (*User, error) {
var user User
objectID := bson.ObjectIdHex(id)
if err := m.getUserCollection().FindId(objectID).One(&user); err != nil {
return nil, err
}
return &user, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Get",
"(",
"id",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"var",
"user",
"User",
"\n\n",
"objectID",
":=",
"bson",
".",
"ObjectIdHex",
"(",
"id",
")",
"\n\n",
"if",
"err",
":=",
"m",
".",
... | // Get user by ID. | [
"Get",
"user",
"by",
"ID",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L78-L88 |
13,942 | itsyouonline/identityserver | db/user/db.go | GetByName | func (m *Manager) GetByName(username string) (*User, error) {
var user User
err := m.getUserCollection().Find(bson.M{"username": username}).One(&user)
if user.Avatars == nil {
user.Avatars = []Avatar{}
}
// Get the facebook and github profile pictures if they are linked to the account
if user.Github.Avatar_url != "" {
user.Avatars = append(user.Avatars, Avatar{Label: "github", Source: user.Github.Avatar_url})
}
if user.Facebook.Link != "" {
user.Avatars = append(user.Avatars, Avatar{Label: "facebook", Source: user.Facebook.Picture})
}
if user.Addresses == nil {
user.Addresses = []Address{}
}
if user.BankAccounts == nil {
user.BankAccounts = []BankAccount{}
}
if user.Phonenumbers == nil {
user.Phonenumbers = []Phonenumber{}
}
if user.EmailAddresses == nil {
user.EmailAddresses = []EmailAddress{}
}
if user.DigitalWallet == nil {
user.DigitalWallet = []DigitalAssetAddress{}
}
if user.PublicKeys == nil {
user.PublicKeys = []PublicKey{}
}
return &user, err
} | go | func (m *Manager) GetByName(username string) (*User, error) {
var user User
err := m.getUserCollection().Find(bson.M{"username": username}).One(&user)
if user.Avatars == nil {
user.Avatars = []Avatar{}
}
// Get the facebook and github profile pictures if they are linked to the account
if user.Github.Avatar_url != "" {
user.Avatars = append(user.Avatars, Avatar{Label: "github", Source: user.Github.Avatar_url})
}
if user.Facebook.Link != "" {
user.Avatars = append(user.Avatars, Avatar{Label: "facebook", Source: user.Facebook.Picture})
}
if user.Addresses == nil {
user.Addresses = []Address{}
}
if user.BankAccounts == nil {
user.BankAccounts = []BankAccount{}
}
if user.Phonenumbers == nil {
user.Phonenumbers = []Phonenumber{}
}
if user.EmailAddresses == nil {
user.EmailAddresses = []EmailAddress{}
}
if user.DigitalWallet == nil {
user.DigitalWallet = []DigitalAssetAddress{}
}
if user.PublicKeys == nil {
user.PublicKeys = []PublicKey{}
}
return &user, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetByName",
"(",
"username",
"string",
")",
"(",
"*",
"User",
",",
"error",
")",
"{",
"var",
"user",
"User",
"\n\n",
"err",
":=",
"m",
".",
"getUserCollection",
"(",
")",
".",
"Find",
"(",
"bson",
".",
"M",
... | //GetByName gets a user by it's username. | [
"GetByName",
"gets",
"a",
"user",
"by",
"it",
"s",
"username",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L91-L125 |
13,943 | itsyouonline/identityserver | db/user/db.go | Save | func (m *Manager) Save(u *User) error {
// TODO: Validation!
if u.ID == "" {
// New Doc!
u.ID = bson.NewObjectId()
err := m.getUserCollection().Insert(u)
return err
}
_, err := m.getUserCollection().UpsertId(u.ID, u)
return err
} | go | func (m *Manager) Save(u *User) error {
// TODO: Validation!
if u.ID == "" {
// New Doc!
u.ID = bson.NewObjectId()
err := m.getUserCollection().Insert(u)
return err
}
_, err := m.getUserCollection().UpsertId(u.ID, u)
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Save",
"(",
"u",
"*",
"User",
")",
"error",
"{",
"// TODO: Validation!",
"if",
"u",
".",
"ID",
"==",
"\"",
"\"",
"{",
"// New Doc!",
"u",
".",
"ID",
"=",
"bson",
".",
"NewObjectId",
"(",
")",
"\n",
"err",
"... | // Save a user. | [
"Save",
"a",
"user",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L140-L153 |
13,944 | itsyouonline/identityserver | db/user/db.go | SaveEmail | func (m *Manager) SaveEmail(username string, email EmailAddress) error {
if err := m.RemoveEmail(username, email.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"emailaddresses": email}})
} | go | func (m *Manager) SaveEmail(username string, email EmailAddress) error {
if err := m.RemoveEmail(username, email.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"emailaddresses": email}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveEmail",
"(",
"username",
"string",
",",
"email",
"EmailAddress",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemoveEmail",
"(",
"username",
",",
"email",
".",
"Label",
")",
";",
"err",
"!=",
"nil",
"{"... | // SaveEmail save or update email along with its label | [
"SaveEmail",
"save",
"or",
"update",
"email",
"along",
"with",
"its",
"label"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L165-L172 |
13,945 | itsyouonline/identityserver | db/user/db.go | SavePublicKey | func (m *Manager) SavePublicKey(username string, key PublicKey) error {
if err := m.RemovePublicKey(username, key.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"publickeys": key}})
} | go | func (m *Manager) SavePublicKey(username string, key PublicKey) error {
if err := m.RemovePublicKey(username, key.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"publickeys": key}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SavePublicKey",
"(",
"username",
"string",
",",
"key",
"PublicKey",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemovePublicKey",
"(",
"username",
",",
"key",
".",
"Label",
")",
";",
"err",
"!=",
"nil",
"{... | // SavePublicKey save or update public key along with its label | [
"SavePublicKey",
"save",
"or",
"update",
"public",
"key",
"along",
"with",
"its",
"label"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L182-L189 |
13,946 | itsyouonline/identityserver | db/user/db.go | SavePhone | func (m *Manager) SavePhone(username string, phonenumber Phonenumber) error {
if err := m.RemovePhone(username, phonenumber.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"phonenumbers": phonenumber}})
} | go | func (m *Manager) SavePhone(username string, phonenumber Phonenumber) error {
if err := m.RemovePhone(username, phonenumber.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"phonenumbers": phonenumber}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SavePhone",
"(",
"username",
"string",
",",
"phonenumber",
"Phonenumber",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemovePhone",
"(",
"username",
",",
"phonenumber",
".",
"Label",
")",
";",
"err",
"!=",
"... | // SavePhone save or update phone along with its label | [
"SavePhone",
"save",
"or",
"update",
"phone",
"along",
"with",
"its",
"label"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L199-L206 |
13,947 | itsyouonline/identityserver | db/user/db.go | SaveVirtualCurrency | func (m *Manager) SaveVirtualCurrency(username string, currency DigitalAssetAddress) error {
if err := m.RemoveVirtualCurrency(username, currency.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"digitalwallet": currency}})
} | go | func (m *Manager) SaveVirtualCurrency(username string, currency DigitalAssetAddress) error {
if err := m.RemoveVirtualCurrency(username, currency.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"digitalwallet": currency}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveVirtualCurrency",
"(",
"username",
"string",
",",
"currency",
"DigitalAssetAddress",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemoveVirtualCurrency",
"(",
"username",
",",
"currency",
".",
"Label",
")",
";"... | // SaveVirtualCurrency save or update virtualcurrency along with its label | [
"SaveVirtualCurrency",
"save",
"or",
"update",
"virtualcurrency",
"along",
"with",
"its",
"label"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L216-L223 |
13,948 | itsyouonline/identityserver | db/user/db.go | SaveAddress | func (m *Manager) SaveAddress(username string, address Address) error {
if err := m.RemoveAddress(username, address.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"addresses": address}})
} | go | func (m *Manager) SaveAddress(username string, address Address) error {
if err := m.RemoveAddress(username, address.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"addresses": address}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveAddress",
"(",
"username",
"string",
",",
"address",
"Address",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemoveAddress",
"(",
"username",
",",
"address",
".",
"Label",
")",
";",
"err",
"!=",
"nil",
... | // SaveAddress save or update address | [
"SaveAddress",
"save",
"or",
"update",
"address"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L233-L240 |
13,949 | itsyouonline/identityserver | db/user/db.go | SaveBank | func (m *Manager) SaveBank(u *User, bank BankAccount) error {
if err := m.RemoveBank(u, bank.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": u.Username},
bson.M{"$push": bson.M{"bankaccounts": bank}})
} | go | func (m *Manager) SaveBank(u *User, bank BankAccount) error {
if err := m.RemoveBank(u, bank.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": u.Username},
bson.M{"$push": bson.M{"bankaccounts": bank}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveBank",
"(",
"u",
"*",
"User",
",",
"bank",
"BankAccount",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemoveBank",
"(",
"u",
",",
"bank",
".",
"Label",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
... | // SaveBank save or update bank account | [
"SaveBank",
"save",
"or",
"update",
"bank",
"account"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L250-L257 |
13,950 | itsyouonline/identityserver | db/user/db.go | RemoveBank | func (m *Manager) RemoveBank(u *User, label string) error {
return m.getUserCollection().Update(
bson.M{"username": u.Username},
bson.M{"$pull": bson.M{"bankaccounts": bson.M{"label": label}}})
} | go | func (m *Manager) RemoveBank(u *User, label string) error {
return m.getUserCollection().Update(
bson.M{"username": u.Username},
bson.M{"$pull": bson.M{"bankaccounts": bson.M{"label": label}}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"RemoveBank",
"(",
"u",
"*",
"User",
",",
"label",
"string",
")",
"error",
"{",
"return",
"m",
".",
"getUserCollection",
"(",
")",
".",
"Update",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"u",
".",
"Usern... | // RemoveBank remove bank associated with label | [
"RemoveBank",
"remove",
"bank",
"associated",
"with",
"label"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L260-L264 |
13,951 | itsyouonline/identityserver | db/user/db.go | GetAuthorizationsByUser | func (m *Manager) GetAuthorizationsByUser(username string) (authorizations []Authorization, err error) {
err = m.getAuthorizationCollection().Find(bson.M{"username": username}).All(&authorizations)
if authorizations == nil {
authorizations = []Authorization{}
}
return
} | go | func (m *Manager) GetAuthorizationsByUser(username string) (authorizations []Authorization, err error) {
err = m.getAuthorizationCollection().Find(bson.M{"username": username}).All(&authorizations)
if authorizations == nil {
authorizations = []Authorization{}
}
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetAuthorizationsByUser",
"(",
"username",
"string",
")",
"(",
"authorizations",
"[",
"]",
"Authorization",
",",
"err",
"error",
")",
"{",
"err",
"=",
"m",
".",
"getAuthorizationCollection",
"(",
")",
".",
"Find",
"(... | // GetAuthorizationsByUser returns all authorizations for a specific user | [
"GetAuthorizationsByUser",
"returns",
"all",
"authorizations",
"for",
"a",
"specific",
"user"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L287-L293 |
13,952 | itsyouonline/identityserver | db/user/db.go | GetOrganizationAuthorizations | func (m *Manager) GetOrganizationAuthorizations(globalId string) (authorizations []Authorization, err error) {
qry := bson.M{"grantedto": globalId}
err = m.getAuthorizationCollection().Find(qry).All(&authorizations)
if authorizations == nil {
authorizations = []Authorization{}
}
return
} | go | func (m *Manager) GetOrganizationAuthorizations(globalId string) (authorizations []Authorization, err error) {
qry := bson.M{"grantedto": globalId}
err = m.getAuthorizationCollection().Find(qry).All(&authorizations)
if authorizations == nil {
authorizations = []Authorization{}
}
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetOrganizationAuthorizations",
"(",
"globalId",
"string",
")",
"(",
"authorizations",
"[",
"]",
"Authorization",
",",
"err",
"error",
")",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"globalId",
"}",... | // GetOrganizationAuthorizations returns all authorizations for a specific organization | [
"GetOrganizationAuthorizations",
"returns",
"all",
"authorizations",
"for",
"a",
"specific",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L296-L303 |
13,953 | itsyouonline/identityserver | db/user/db.go | GetAuthorization | func (m *Manager) GetAuthorization(username, organization string) (authorization *Authorization, err error) {
err = m.getAuthorizationCollection().Find(bson.M{"username": username, "grantedto": organization}).One(&authorization)
if err == mgo.ErrNotFound {
err = nil
} else if err != nil {
authorization = nil
}
return
} | go | func (m *Manager) GetAuthorization(username, organization string) (authorization *Authorization, err error) {
err = m.getAuthorizationCollection().Find(bson.M{"username": username, "grantedto": organization}).One(&authorization)
if err == mgo.ErrNotFound {
err = nil
} else if err != nil {
authorization = nil
}
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetAuthorization",
"(",
"username",
",",
"organization",
"string",
")",
"(",
"authorization",
"*",
"Authorization",
",",
"err",
"error",
")",
"{",
"err",
"=",
"m",
".",
"getAuthorizationCollection",
"(",
")",
".",
"F... | //GetAuthorization returns the authorization for a specific organization, nil if no such authorization exists | [
"GetAuthorization",
"returns",
"the",
"authorization",
"for",
"a",
"specific",
"organization",
"nil",
"if",
"no",
"such",
"authorization",
"exists"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L306-L314 |
13,954 | itsyouonline/identityserver | db/user/db.go | FilterUsersWithAuthorizations | func (m *Manager) FilterUsersWithAuthorizations(usernames []string, organization string) ([]string, error) {
var auths []Authorization
err := m.getAuthorizationCollection().Find(bson.M{"username": bson.M{"$in": usernames}, "grantedto": organization}).Select(bson.M{"username": 1}).All(&auths)
if err != nil {
return nil, err
}
result := []string{}
for _, auth := range auths {
result = append(result, auth.Username)
}
return result, nil
} | go | func (m *Manager) FilterUsersWithAuthorizations(usernames []string, organization string) ([]string, error) {
var auths []Authorization
err := m.getAuthorizationCollection().Find(bson.M{"username": bson.M{"$in": usernames}, "grantedto": organization}).Select(bson.M{"username": 1}).All(&auths)
if err != nil {
return nil, err
}
result := []string{}
for _, auth := range auths {
result = append(result, auth.Username)
}
return result, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"FilterUsersWithAuthorizations",
"(",
"usernames",
"[",
"]",
"string",
",",
"organization",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"auths",
"[",
"]",
"Authorization",
"\n",
"err",
":=... | // FilterUsersWithAuthorizations returns the authorizations granted to an organization | [
"FilterUsersWithAuthorizations",
"returns",
"the",
"authorizations",
"granted",
"to",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L317-L328 |
13,955 | itsyouonline/identityserver | db/user/db.go | UpdateAuthorization | func (m *Manager) UpdateAuthorization(authorization *Authorization) (err error) {
_, err = m.getAuthorizationCollection().Upsert(bson.M{"username": authorization.Username, "grantedto": authorization.GrantedTo}, authorization)
return
} | go | func (m *Manager) UpdateAuthorization(authorization *Authorization) (err error) {
_, err = m.getAuthorizationCollection().Upsert(bson.M{"username": authorization.Username, "grantedto": authorization.GrantedTo}, authorization)
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"UpdateAuthorization",
"(",
"authorization",
"*",
"Authorization",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"m",
".",
"getAuthorizationCollection",
"(",
")",
".",
"Upsert",
"(",
"bson",
".",
"M",
... | //UpdateAuthorization inserts or updates an authorization | [
"UpdateAuthorization",
"inserts",
"or",
"updates",
"an",
"authorization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L331-L334 |
13,956 | itsyouonline/identityserver | db/user/db.go | DeleteAuthorization | func (m *Manager) DeleteAuthorization(username, organization string) (err error) {
_, err = m.getAuthorizationCollection().RemoveAll(bson.M{"username": username, "grantedto": organization})
return
} | go | func (m *Manager) DeleteAuthorization(username, organization string) (err error) {
_, err = m.getAuthorizationCollection().RemoveAll(bson.M{"username": username, "grantedto": organization})
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"DeleteAuthorization",
"(",
"username",
",",
"organization",
"string",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"m",
".",
"getAuthorizationCollection",
"(",
")",
".",
"RemoveAll",
"(",
"bson",
".",
... | //DeleteAuthorization removes an authorization | [
"DeleteAuthorization",
"removes",
"an",
"authorization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L337-L340 |
13,957 | itsyouonline/identityserver | db/user/db.go | DeleteAllAuthorizations | func (m *Manager) DeleteAllAuthorizations(organization string) (err error) {
_, err = m.getAuthorizationCollection().RemoveAll(bson.M{"grantedto": organization})
return err
} | go | func (m *Manager) DeleteAllAuthorizations(organization string) (err error) {
_, err = m.getAuthorizationCollection().RemoveAll(bson.M{"grantedto": organization})
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"DeleteAllAuthorizations",
"(",
"organization",
"string",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"m",
".",
"getAuthorizationCollection",
"(",
")",
".",
"RemoveAll",
"(",
"bson",
".",
"M",
"{",
"... | //DeleteAllAuthorizations removes all authorizations from an organization | [
"DeleteAllAuthorizations",
"removes",
"all",
"authorizations",
"from",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L343-L346 |
13,958 | itsyouonline/identityserver | db/user/db.go | SaveAvatar | func (m *Manager) SaveAvatar(username string, avatar Avatar) error {
if err := m.RemoveAvatar(username, avatar.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"avatars": avatar}})
} | go | func (m *Manager) SaveAvatar(username string, avatar Avatar) error {
if err := m.RemoveAvatar(username, avatar.Label); err != nil {
return err
}
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$push": bson.M{"avatars": avatar}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveAvatar",
"(",
"username",
"string",
",",
"avatar",
"Avatar",
")",
"error",
"{",
"if",
"err",
":=",
"m",
".",
"RemoveAvatar",
"(",
"username",
",",
"avatar",
".",
"Label",
")",
";",
"err",
"!=",
"nil",
"{",
... | // SaveAvatar saves a new or updates an existing avatar | [
"SaveAvatar",
"saves",
"a",
"new",
"or",
"updates",
"an",
"existing",
"avatar"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L379-L386 |
13,959 | itsyouonline/identityserver | db/user/db.go | RemoveAvatar | func (m *Manager) RemoveAvatar(username, label string) error {
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$pull": bson.M{"avatars": bson.M{"label": label}}})
} | go | func (m *Manager) RemoveAvatar(username, label string) error {
return m.getUserCollection().Update(
bson.M{"username": username},
bson.M{"$pull": bson.M{"avatars": bson.M{"label": label}}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"RemoveAvatar",
"(",
"username",
",",
"label",
"string",
")",
"error",
"{",
"return",
"m",
".",
"getUserCollection",
"(",
")",
".",
"Update",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"username",
"}",
",",
... | // RemoveAvatar removes an avatar | [
"RemoveAvatar",
"removes",
"an",
"avatar"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L389-L393 |
13,960 | itsyouonline/identityserver | db/user/db.go | AvatarFileExists | func (m *Manager) AvatarFileExists(hash string) (bool, error) {
count, err := m.getAvatarFileCollection().Find(bson.M{"hash": hash}).Count()
return count >= 1, err
} | go | func (m *Manager) AvatarFileExists(hash string) (bool, error) {
count, err := m.getAvatarFileCollection().Find(bson.M{"hash": hash}).Count()
return count >= 1, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AvatarFileExists",
"(",
"hash",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"m",
".",
"getAvatarFileCollection",
"(",
")",
".",
"Find",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"... | // AvatarFileExists checks if an avatarfile with a given hash already exists | [
"AvatarFileExists",
"checks",
"if",
"an",
"avatarfile",
"with",
"a",
"given",
"hash",
"already",
"exists"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L396-L400 |
13,961 | itsyouonline/identityserver | db/user/db.go | GetAvatarFile | func (m *Manager) GetAvatarFile(hash string) ([]byte, error) {
var file struct {
Hash string
File []byte
}
err := m.getAvatarFileCollection().Find(bson.M{"hash": hash}).One(&file)
if err == mgo.ErrNotFound {
return nil, nil
}
return file.File, err
} | go | func (m *Manager) GetAvatarFile(hash string) ([]byte, error) {
var file struct {
Hash string
File []byte
}
err := m.getAvatarFileCollection().Find(bson.M{"hash": hash}).One(&file)
if err == mgo.ErrNotFound {
return nil, nil
}
return file.File, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetAvatarFile",
"(",
"hash",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"file",
"struct",
"{",
"Hash",
"string",
"\n",
"File",
"[",
"]",
"byte",
"\n",
"}",
"\n\n",
"err",
":=",
"m"... | // GetAvatarFile gets the avatar file associated with a hash | [
"GetAvatarFile",
"gets",
"the",
"avatar",
"file",
"associated",
"with",
"a",
"hash"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L403-L414 |
13,962 | itsyouonline/identityserver | db/user/db.go | SaveAvatarFile | func (m *Manager) SaveAvatarFile(hash string, file []byte) error {
_, err := m.getAvatarFileCollection().Upsert(
bson.M{"hash": hash},
bson.M{"$set": bson.M{"file": file}})
return err
} | go | func (m *Manager) SaveAvatarFile(hash string, file []byte) error {
_, err := m.getAvatarFileCollection().Upsert(
bson.M{"hash": hash},
bson.M{"$set": bson.M{"file": file}})
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveAvatarFile",
"(",
"hash",
"string",
",",
"file",
"[",
"]",
"byte",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"getAvatarFileCollection",
"(",
")",
".",
"Upsert",
"(",
"bson",
".",
"M",
"{",
"\"",... | // SaveAvatarFile saves a new avatar file | [
"SaveAvatarFile",
"saves",
"a",
"new",
"avatar",
"file"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L417-L422 |
13,963 | itsyouonline/identityserver | db/user/db.go | RemoveAvatarFile | func (m *Manager) RemoveAvatarFile(hash string) error {
return m.getAvatarFileCollection().Remove(bson.M{"hash": hash})
} | go | func (m *Manager) RemoveAvatarFile(hash string) error {
return m.getAvatarFileCollection().Remove(bson.M{"hash": hash})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"RemoveAvatarFile",
"(",
"hash",
"string",
")",
"error",
"{",
"return",
"m",
".",
"getAvatarFileCollection",
"(",
")",
".",
"Remove",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"hash",
"}",
")",
"\n",
"}"
] | // RemoveAvatarFile removes an avatar file | [
"RemoveAvatarFile",
"removes",
"an",
"avatar",
"file"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/db.go#L425-L427 |
13,964 | itsyouonline/identityserver | db/see/db.go | GetSeeObjects | func (m *Manager) GetSeeObjects(username string) (seeObjects []See, err error) {
qry := bson.M{"username": username}
err = m.collection.Find(qry).Sort("-versions.creationdate").All(&seeObjects)
if seeObjects == nil {
seeObjects = []See{}
}
return
} | go | func (m *Manager) GetSeeObjects(username string) (seeObjects []See, err error) {
qry := bson.M{"username": username}
err = m.collection.Find(qry).Sort("-versions.creationdate").All(&seeObjects)
if seeObjects == nil {
seeObjects = []See{}
}
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetSeeObjects",
"(",
"username",
"string",
")",
"(",
"seeObjects",
"[",
"]",
"See",
",",
"err",
"error",
")",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"username",
"}",
"\n",
"err",
"=",
"m"... | // GetSeeObjects returns all see object for a specific username | [
"GetSeeObjects",
"returns",
"all",
"see",
"object",
"for",
"a",
"specific",
"username"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/see/db.go#L47-L54 |
13,965 | itsyouonline/identityserver | db/see/db.go | GetSeeObject | func (m *Manager) GetSeeObject(username string, globalID string, uniqueID string) (seeObject *See, err error) {
qry := bson.M{"username": username, "globalid": globalID, "uniqueid": uniqueID}
err = m.collection.Find(qry).One(&seeObject)
return
} | go | func (m *Manager) GetSeeObject(username string, globalID string, uniqueID string) (seeObject *See, err error) {
qry := bson.M{"username": username, "globalid": globalID, "uniqueid": uniqueID}
err = m.collection.Find(qry).One(&seeObject)
return
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetSeeObject",
"(",
"username",
"string",
",",
"globalID",
"string",
",",
"uniqueID",
"string",
")",
"(",
"seeObject",
"*",
"See",
",",
"err",
"error",
")",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
... | // GetSeeObject returns a see object | [
"GetSeeObject",
"returns",
"a",
"see",
"object"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/see/db.go#L67-L71 |
13,966 | itsyouonline/identityserver | db/see/db.go | Create | func (m *Manager) Create(see *See) error {
see.ID = bson.NewObjectId()
err := m.collection.Insert(see)
if mgo.IsDup(err) {
return db.ErrDuplicate
}
return err
} | go | func (m *Manager) Create(see *See) error {
see.ID = bson.NewObjectId()
err := m.collection.Insert(see)
if mgo.IsDup(err) {
return db.ErrDuplicate
}
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Create",
"(",
"see",
"*",
"See",
")",
"error",
"{",
"see",
".",
"ID",
"=",
"bson",
".",
"NewObjectId",
"(",
")",
"\n",
"err",
":=",
"m",
".",
"collection",
".",
"Insert",
"(",
"see",
")",
"\n",
"if",
"mgo... | // Create an object | [
"Create",
"an",
"object"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/see/db.go#L74-L81 |
13,967 | itsyouonline/identityserver | db/see/db.go | AddVersion | func (m *Manager) AddVersion(username string, globalID string, uniqueID string, seeVersion *SeeVersion) error {
qry := bson.M{"username": username, "globalid": globalID, "uniqueid": uniqueID}
return m.collection.Update(qry, bson.M{"$push": bson.M{"versions": seeVersion}})
} | go | func (m *Manager) AddVersion(username string, globalID string, uniqueID string, seeVersion *SeeVersion) error {
qry := bson.M{"username": username, "globalid": globalID, "uniqueid": uniqueID}
return m.collection.Update(qry, bson.M{"$push": bson.M{"versions": seeVersion}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AddVersion",
"(",
"username",
"string",
",",
"globalID",
"string",
",",
"uniqueID",
"string",
",",
"seeVersion",
"*",
"SeeVersion",
")",
"error",
"{",
"qry",
":=",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"usernam... | // AddVersion adds a new version to the object | [
"AddVersion",
"adds",
"a",
"new",
"version",
"to",
"the",
"object"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/see/db.go#L84-L87 |
13,968 | itsyouonline/identityserver | db/see/db.go | Update | func (m *Manager) Update(see *See) error {
return m.collection.UpdateId(see.ID, see)
} | go | func (m *Manager) Update(see *See) error {
return m.collection.UpdateId(see.ID, see)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Update",
"(",
"see",
"*",
"See",
")",
"error",
"{",
"return",
"m",
".",
"collection",
".",
"UpdateId",
"(",
"see",
".",
"ID",
",",
"see",
")",
"\n",
"}"
] | // Update adds a signature to an existing version | [
"Update",
"adds",
"a",
"signature",
"to",
"an",
"existing",
"version"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/see/db.go#L90-L92 |
13,969 | itsyouonline/identityserver | identityservice/contract/contracthelper.go | CreateContract | func CreateContract(w http.ResponseWriter, r *http.Request, includedparty contractdb.Party) {
contract := &contractdb.Contract{}
if err := json.NewDecoder(r.Body).Decode(contract); err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
if contract.ContractId == "" {
log.Debug("ContractId can not be empty")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
hasuser := false
for _, party := range contract.Parties {
if party.Type == includedparty.Type && party.Name == includedparty.Name {
hasuser = true
}
}
if !hasuser {
contract.Parties = append(contract.Parties, includedparty)
}
contractMngr := contractdb.NewManager(r)
err := contractMngr.Save(contract)
if err != nil {
log.Error("ERROR while saving contracts :\n", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(&contract)
} | go | func CreateContract(w http.ResponseWriter, r *http.Request, includedparty contractdb.Party) {
contract := &contractdb.Contract{}
if err := json.NewDecoder(r.Body).Decode(contract); err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
if contract.ContractId == "" {
log.Debug("ContractId can not be empty")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
hasuser := false
for _, party := range contract.Parties {
if party.Type == includedparty.Type && party.Name == includedparty.Name {
hasuser = true
}
}
if !hasuser {
contract.Parties = append(contract.Parties, includedparty)
}
contractMngr := contractdb.NewManager(r)
err := contractMngr.Save(contract)
if err != nil {
log.Error("ERROR while saving contracts :\n", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(&contract)
} | [
"func",
"CreateContract",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"includedparty",
"contractdb",
".",
"Party",
")",
"{",
"contract",
":=",
"&",
"contractdb",
".",
"Contract",
"{",
"}",
"\n",
"if",
"err",
":=",... | //CreateContract will save contract | [
"CreateContract",
"will",
"save",
"contract"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/contract/contracthelper.go#L13-L42 |
13,970 | itsyouonline/identityserver | identityservice/contract/contracthelper.go | FindContracts | func FindContracts(w http.ResponseWriter, r *http.Request, includedparty contractdb.Party) {
contractMngr := contractdb.NewManager(r)
includeexpired := false
if r.URL.Query().Get("includeExpired") == "true" {
includeexpired = true
}
startstr := r.URL.Query().Get("start")
start := 0
var err error
if startstr != "" {
start, err = strconv.Atoi(startstr)
if err != nil {
log.Debug("Could not parse start: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
}
maxstr := r.URL.Query().Get("max")
max := 50
if maxstr != "" {
max, err = strconv.Atoi(maxstr)
if err != nil {
log.Debug("Could not parse max: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
}
contracts, err := contractMngr.GetByIncludedParty(&includedparty, start, max, includeexpired)
if err != nil {
log.Error("ERROR while getting contracts :\n", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.Header().Set("Content-type", "application/json")
json.NewEncoder(w).Encode(&contracts)
} | go | func FindContracts(w http.ResponseWriter, r *http.Request, includedparty contractdb.Party) {
contractMngr := contractdb.NewManager(r)
includeexpired := false
if r.URL.Query().Get("includeExpired") == "true" {
includeexpired = true
}
startstr := r.URL.Query().Get("start")
start := 0
var err error
if startstr != "" {
start, err = strconv.Atoi(startstr)
if err != nil {
log.Debug("Could not parse start: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
}
maxstr := r.URL.Query().Get("max")
max := 50
if maxstr != "" {
max, err = strconv.Atoi(maxstr)
if err != nil {
log.Debug("Could not parse max: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
}
contracts, err := contractMngr.GetByIncludedParty(&includedparty, start, max, includeexpired)
if err != nil {
log.Error("ERROR while getting contracts :\n", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.Header().Set("Content-type", "application/json")
json.NewEncoder(w).Encode(&contracts)
} | [
"func",
"FindContracts",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"includedparty",
"contractdb",
".",
"Party",
")",
"{",
"contractMngr",
":=",
"contractdb",
".",
"NewManager",
"(",
"r",
")",
"\n",
"includeexpired",... | //FindContracts for query | [
"FindContracts",
"for",
"query"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/contract/contracthelper.go#L45-L81 |
13,971 | itsyouonline/identityserver | credentials/password/keyderivation/keyderivation.go | Check | func Check(password, key string) bool {
err := sha512crypt.New().Verify(key, []byte(password))
return err == nil
} | go | func Check(password, key string) bool {
err := sha512crypt.New().Verify(key, []byte(password))
return err == nil
} | [
"func",
"Check",
"(",
"password",
",",
"key",
"string",
")",
"bool",
"{",
"err",
":=",
"sha512crypt",
".",
"New",
"(",
")",
".",
"Verify",
"(",
"key",
",",
"[",
"]",
"byte",
"(",
"password",
")",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"... | //Check takes the password and the encoded key
// and checks if the combination matches | [
"Check",
"takes",
"the",
"password",
"and",
"the",
"encoded",
"key",
"and",
"checks",
"if",
"the",
"combination",
"matches"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/keyderivation/keyderivation.go#L18-L21 |
13,972 | itsyouonline/identityserver | db/user/Authorization.go | LabelledPropertyIsAuthorized | func LabelledPropertyIsAuthorized(scope string, scopePrefix string, authorizedLabels []AuthorizationMap) (authorized bool) {
if authorizedLabels == nil {
return
}
if scope == scopePrefix {
authorized = len(authorizedLabels) > 0
return
}
if strings.HasPrefix(scope, scopePrefix+":") {
split := strings.Split(strings.TrimPrefix(scope, scopePrefix+":"), ":")
requestedLabel := split[0]
requestedScope := split[len(split)-1]
if requestedLabel == requestedScope {
requestedScope = ""
}
for _, authorizationmap := range authorizedLabels {
if (authorizationmap.RequestedLabel == requestedLabel ||
authorizationmap.RequestedLabel == "main" && requestedLabel == "") &&
(authorizationmap.Scope == requestedScope || requestedScope == "") {
authorized = true
return
}
}
}
return
} | go | func LabelledPropertyIsAuthorized(scope string, scopePrefix string, authorizedLabels []AuthorizationMap) (authorized bool) {
if authorizedLabels == nil {
return
}
if scope == scopePrefix {
authorized = len(authorizedLabels) > 0
return
}
if strings.HasPrefix(scope, scopePrefix+":") {
split := strings.Split(strings.TrimPrefix(scope, scopePrefix+":"), ":")
requestedLabel := split[0]
requestedScope := split[len(split)-1]
if requestedLabel == requestedScope {
requestedScope = ""
}
for _, authorizationmap := range authorizedLabels {
if (authorizationmap.RequestedLabel == requestedLabel ||
authorizationmap.RequestedLabel == "main" && requestedLabel == "") &&
(authorizationmap.Scope == requestedScope || requestedScope == "") {
authorized = true
return
}
}
}
return
} | [
"func",
"LabelledPropertyIsAuthorized",
"(",
"scope",
"string",
",",
"scopePrefix",
"string",
",",
"authorizedLabels",
"[",
"]",
"AuthorizationMap",
")",
"(",
"authorized",
"bool",
")",
"{",
"if",
"authorizedLabels",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
... | // LabelledPropertyIsAuthorized checks if a labelled property is authorized | [
"LabelledPropertyIsAuthorized",
"checks",
"if",
"a",
"labelled",
"property",
"is",
"authorized"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Authorization.go#L122-L147 |
13,973 | itsyouonline/identityserver | db/user/Authorization.go | Merge | func (auth *Authorization) Merge(a *Authorization) {
// Merge all but the grantedTo and username fields, those are already the same
// Do some sanity checking anyway
if auth.Username != a.Username || auth.GrantedTo != a.GrantedTo {
return
}
// Bool fields are merged on a once given is alwasy given basis
auth.Facebook = auth.Facebook || a.Facebook
auth.Github = auth.Github || a.Github
auth.Name = auth.Name || a.Name
auth.KeyStore = auth.KeyStore || a.KeyStore
auth.See = auth.See || a.See
// Authorized organizations can simply be expanded
auth.Organizations = append(auth.Organizations, a.Organizations...)
// Ownerof is an abstraction over a []string, can also be expanded
auth.OwnerOf.EmailAddresses = append(auth.OwnerOf.EmailAddresses, a.OwnerOf.EmailAddresses...)
// DigitalWallet is a separate type
auth.DigitalWallet = mergeDigitalWalletAuthorizationMap(auth.DigitalWallet, a.DigitalWallet)
// Merge the authorization maps
auth.Addresses = mergeAuthorizationMaps(auth.Addresses, a.Addresses)
auth.Avatars = mergeAuthorizationMaps(auth.Avatars, a.Avatars)
auth.BankAccounts = mergeAuthorizationMaps(auth.BankAccounts, a.BankAccounts)
auth.EmailAddresses = mergeAuthorizationMaps(auth.EmailAddresses, a.EmailAddresses)
auth.Phonenumbers = mergeAuthorizationMaps(auth.Phonenumbers, a.Phonenumbers)
auth.PublicKeys = mergeAuthorizationMaps(auth.PublicKeys, a.PublicKeys)
auth.ValidatedEmailAddresses = mergeAuthorizationMaps(auth.ValidatedEmailAddresses, a.ValidatedEmailAddresses)
auth.ValidatedPhonenumbers = mergeAuthorizationMaps(auth.ValidatedPhonenumbers, a.ValidatedPhonenumbers)
} | go | func (auth *Authorization) Merge(a *Authorization) {
// Merge all but the grantedTo and username fields, those are already the same
// Do some sanity checking anyway
if auth.Username != a.Username || auth.GrantedTo != a.GrantedTo {
return
}
// Bool fields are merged on a once given is alwasy given basis
auth.Facebook = auth.Facebook || a.Facebook
auth.Github = auth.Github || a.Github
auth.Name = auth.Name || a.Name
auth.KeyStore = auth.KeyStore || a.KeyStore
auth.See = auth.See || a.See
// Authorized organizations can simply be expanded
auth.Organizations = append(auth.Organizations, a.Organizations...)
// Ownerof is an abstraction over a []string, can also be expanded
auth.OwnerOf.EmailAddresses = append(auth.OwnerOf.EmailAddresses, a.OwnerOf.EmailAddresses...)
// DigitalWallet is a separate type
auth.DigitalWallet = mergeDigitalWalletAuthorizationMap(auth.DigitalWallet, a.DigitalWallet)
// Merge the authorization maps
auth.Addresses = mergeAuthorizationMaps(auth.Addresses, a.Addresses)
auth.Avatars = mergeAuthorizationMaps(auth.Avatars, a.Avatars)
auth.BankAccounts = mergeAuthorizationMaps(auth.BankAccounts, a.BankAccounts)
auth.EmailAddresses = mergeAuthorizationMaps(auth.EmailAddresses, a.EmailAddresses)
auth.Phonenumbers = mergeAuthorizationMaps(auth.Phonenumbers, a.Phonenumbers)
auth.PublicKeys = mergeAuthorizationMaps(auth.PublicKeys, a.PublicKeys)
auth.ValidatedEmailAddresses = mergeAuthorizationMaps(auth.ValidatedEmailAddresses, a.ValidatedEmailAddresses)
auth.ValidatedPhonenumbers = mergeAuthorizationMaps(auth.ValidatedPhonenumbers, a.ValidatedPhonenumbers)
} | [
"func",
"(",
"auth",
"*",
"Authorization",
")",
"Merge",
"(",
"a",
"*",
"Authorization",
")",
"{",
"// Merge all but the grantedTo and username fields, those are already the same",
"// Do some sanity checking anyway",
"if",
"auth",
".",
"Username",
"!=",
"a",
".",
"Userna... | // Merge merges 2 authorizations. | [
"Merge",
"merges",
"2",
"authorizations",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Authorization.go#L150-L182 |
13,974 | itsyouonline/identityserver | db/user/Authorization.go | mergeAuthorizationMaps | func mergeAuthorizationMaps(newAuths []AuthorizationMap, oldAuths []AuthorizationMap) []AuthorizationMap {
OLDAUTHS:
for _, oldAuth := range oldAuths {
// check all new auths to make sure it isn't overwritten
for _, newAuth := range newAuths {
// overwritten, continue with the next oldAuth
if oldAuth.RequestedLabel == newAuth.RequestedLabel {
continue OLDAUTHS
}
}
// All new auths checked and no match, so lets append it
newAuths = append(newAuths, oldAuth)
}
return newAuths
} | go | func mergeAuthorizationMaps(newAuths []AuthorizationMap, oldAuths []AuthorizationMap) []AuthorizationMap {
OLDAUTHS:
for _, oldAuth := range oldAuths {
// check all new auths to make sure it isn't overwritten
for _, newAuth := range newAuths {
// overwritten, continue with the next oldAuth
if oldAuth.RequestedLabel == newAuth.RequestedLabel {
continue OLDAUTHS
}
}
// All new auths checked and no match, so lets append it
newAuths = append(newAuths, oldAuth)
}
return newAuths
} | [
"func",
"mergeAuthorizationMaps",
"(",
"newAuths",
"[",
"]",
"AuthorizationMap",
",",
"oldAuths",
"[",
"]",
"AuthorizationMap",
")",
"[",
"]",
"AuthorizationMap",
"{",
"OLDAUTHS",
":",
"for",
"_",
",",
"oldAuth",
":=",
"range",
"oldAuths",
"{",
"// check all new... | // mergeAuthorizationMaps merges 2 authorizationmaps, overwriting requestedlabels
// with those from the authorizationmap provided by the new Authorization | [
"mergeAuthorizationMaps",
"merges",
"2",
"authorizationmaps",
"overwriting",
"requestedlabels",
"with",
"those",
"from",
"the",
"authorizationmap",
"provided",
"by",
"the",
"new",
"Authorization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Authorization.go#L186-L201 |
13,975 | itsyouonline/identityserver | db/user/Authorization.go | mergeDigitalWalletAuthorizationMap | func mergeDigitalWalletAuthorizationMap(newAuths []DigitalWalletAuthorization, oldAuths []DigitalWalletAuthorization) []DigitalWalletAuthorization {
OLDAUTHS:
for _, oldAuth := range oldAuths {
// check all new auths to make sure it isn't overwritten
for _, newAuth := range newAuths {
// overwritten, continue with the next oldAuth
if oldAuth.RequestedLabel == newAuth.RequestedLabel {
continue OLDAUTHS
}
}
// All new auths checked and no match, so lets append it
newAuths = append(newAuths, oldAuth)
}
return newAuths
} | go | func mergeDigitalWalletAuthorizationMap(newAuths []DigitalWalletAuthorization, oldAuths []DigitalWalletAuthorization) []DigitalWalletAuthorization {
OLDAUTHS:
for _, oldAuth := range oldAuths {
// check all new auths to make sure it isn't overwritten
for _, newAuth := range newAuths {
// overwritten, continue with the next oldAuth
if oldAuth.RequestedLabel == newAuth.RequestedLabel {
continue OLDAUTHS
}
}
// All new auths checked and no match, so lets append it
newAuths = append(newAuths, oldAuth)
}
return newAuths
} | [
"func",
"mergeDigitalWalletAuthorizationMap",
"(",
"newAuths",
"[",
"]",
"DigitalWalletAuthorization",
",",
"oldAuths",
"[",
"]",
"DigitalWalletAuthorization",
")",
"[",
"]",
"DigitalWalletAuthorization",
"{",
"OLDAUTHS",
":",
"for",
"_",
",",
"oldAuth",
":=",
"range"... | // Mainly coppied over from mergeAuthorizationMaps | [
"Mainly",
"coppied",
"over",
"from",
"mergeAuthorizationMaps"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Authorization.go#L204-L219 |
13,976 | itsyouonline/identityserver | db/user/Authorization.go | DigitalWalletIsAuthorized | func DigitalWalletIsAuthorized(scope string, scopePrefix string, authorizedLabels []DigitalWalletAuthorization) (authorized bool) {
if authorizedLabels == nil {
return
}
if scope == scopePrefix {
authorized = len(authorizedLabels) > 0
return
}
if strings.HasPrefix(scope, scopePrefix+":") {
requestedLabel := strings.Split(strings.TrimPrefix(scope, scopePrefix+":"), ":")[0]
for _, authorizationmap := range authorizedLabels {
if authorizationmap.RequestedLabel == requestedLabel || authorizationmap.RequestedLabel == "main" && requestedLabel == "" {
authorized = true
return
}
}
}
return
} | go | func DigitalWalletIsAuthorized(scope string, scopePrefix string, authorizedLabels []DigitalWalletAuthorization) (authorized bool) {
if authorizedLabels == nil {
return
}
if scope == scopePrefix {
authorized = len(authorizedLabels) > 0
return
}
if strings.HasPrefix(scope, scopePrefix+":") {
requestedLabel := strings.Split(strings.TrimPrefix(scope, scopePrefix+":"), ":")[0]
for _, authorizationmap := range authorizedLabels {
if authorizationmap.RequestedLabel == requestedLabel || authorizationmap.RequestedLabel == "main" && requestedLabel == "" {
authorized = true
return
}
}
}
return
} | [
"func",
"DigitalWalletIsAuthorized",
"(",
"scope",
"string",
",",
"scopePrefix",
"string",
",",
"authorizedLabels",
"[",
"]",
"DigitalWalletAuthorization",
")",
"(",
"authorized",
"bool",
")",
"{",
"if",
"authorizedLabels",
"==",
"nil",
"{",
"return",
"\n",
"}",
... | // DigitalWalletIsAuthorized checks if a digital wallet is authorized | [
"DigitalWalletIsAuthorized",
"checks",
"if",
"a",
"digital",
"wallet",
"is",
"authorized"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/user/Authorization.go#L222-L240 |
13,977 | itsyouonline/identityserver | credentials/password/keyderivation/crypt/common/base64.go | Base64_24Bit | func Base64_24Bit(src []byte) (hash []byte) {
if len(src) == 0 {
return []byte{} // TODO: return nil
}
hashSize := (len(src) * 8) / 6
if (len(src) % 6) != 0 {
hashSize++
}
hash = make([]byte, hashSize)
dst := hash
for len(src) > 0 {
switch len(src) {
default:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[((src[0]>>6)|(src[1]<<2))&0x3f]
dst[2] = alphabet[((src[1]>>4)|(src[2]<<4))&0x3f]
dst[3] = alphabet[(src[2]>>2)&0x3f]
src = src[3:]
dst = dst[4:]
case 2:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[((src[0]>>6)|(src[1]<<2))&0x3f]
dst[2] = alphabet[(src[1]>>4)&0x3f]
src = src[2:]
dst = dst[3:]
case 1:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[(src[0]>>6)&0x3f]
src = src[1:]
dst = dst[2:]
}
}
return
} | go | func Base64_24Bit(src []byte) (hash []byte) {
if len(src) == 0 {
return []byte{} // TODO: return nil
}
hashSize := (len(src) * 8) / 6
if (len(src) % 6) != 0 {
hashSize++
}
hash = make([]byte, hashSize)
dst := hash
for len(src) > 0 {
switch len(src) {
default:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[((src[0]>>6)|(src[1]<<2))&0x3f]
dst[2] = alphabet[((src[1]>>4)|(src[2]<<4))&0x3f]
dst[3] = alphabet[(src[2]>>2)&0x3f]
src = src[3:]
dst = dst[4:]
case 2:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[((src[0]>>6)|(src[1]<<2))&0x3f]
dst[2] = alphabet[(src[1]>>4)&0x3f]
src = src[2:]
dst = dst[3:]
case 1:
dst[0] = alphabet[src[0]&0x3f]
dst[1] = alphabet[(src[0]>>6)&0x3f]
src = src[1:]
dst = dst[2:]
}
}
return
} | [
"func",
"Base64_24Bit",
"(",
"src",
"[",
"]",
"byte",
")",
"(",
"hash",
"[",
"]",
"byte",
")",
"{",
"if",
"len",
"(",
"src",
")",
"==",
"0",
"{",
"return",
"[",
"]",
"byte",
"{",
"}",
"// TODO: return nil",
"\n",
"}",
"\n\n",
"hashSize",
":=",
"(... | // Base64_24Bit is a variant of Base64 encoding, commonly used with password
// hashing algorithms to encode the result of their checksum output.
//
// The algorithm operates on up to 3 bytes at a time, encoding the following
// 6-bit sequences into up to 4 hash64 ASCII bytes.
//
// 1. Bottom 6 bits of the first byte
// 2. Top 2 bits of the first byte, and bottom 4 bits of the second byte.
// 3. Top 4 bits of the second byte, and bottom 2 bits of the third byte.
// 4. Top 6 bits of the third byte.
//
// This encoding method does not emit padding bytes as Base64 does. | [
"Base64_24Bit",
"is",
"a",
"variant",
"of",
"Base64",
"encoding",
"commonly",
"used",
"with",
"password",
"hashing",
"algorithms",
"to",
"encode",
"the",
"result",
"of",
"their",
"checksum",
"output",
".",
"The",
"algorithm",
"operates",
"on",
"up",
"to",
"3",... | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/keyderivation/crypt/common/base64.go#L25-L61 |
13,978 | itsyouonline/identityserver | db/validation/db.go | SavePhonenumberValidationInformation | func (manager *Manager) SavePhonenumberValidationInformation(info *PhonenumberValidationInformation) (err error) {
mgoCollection := db.GetCollection(manager.session, mongoOngoingPhonenumberValidationCollectionName)
_, err = mgoCollection.Upsert(bson.M{"phonenumber": info.Phonenumber}, info)
return
} | go | func (manager *Manager) SavePhonenumberValidationInformation(info *PhonenumberValidationInformation) (err error) {
mgoCollection := db.GetCollection(manager.session, mongoOngoingPhonenumberValidationCollectionName)
_, err = mgoCollection.Upsert(bson.M{"phonenumber": info.Phonenumber}, info)
return
} | [
"func",
"(",
"manager",
"*",
"Manager",
")",
"SavePhonenumberValidationInformation",
"(",
"info",
"*",
"PhonenumberValidationInformation",
")",
"(",
"err",
"error",
")",
"{",
"mgoCollection",
":=",
"db",
".",
"GetCollection",
"(",
"manager",
".",
"session",
",",
... | //SavePhonenumberValidationInformation stores a validated phonenumber. | [
"SavePhonenumberValidationInformation",
"stores",
"a",
"validated",
"phonenumber",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/validation/db.go#L121-L125 |
13,979 | itsyouonline/identityserver | db/validation/db.go | SaveEmailAddressValidationInformation | func (manager *Manager) SaveEmailAddressValidationInformation(info *EmailAddressValidationInformation) (err error) {
mgoCollection := db.GetCollection(manager.session, mongoOngoingEmailAddressValidationCollectionName)
_, err = mgoCollection.Upsert(bson.M{"emailaddress": info.EmailAddress}, info)
return
} | go | func (manager *Manager) SaveEmailAddressValidationInformation(info *EmailAddressValidationInformation) (err error) {
mgoCollection := db.GetCollection(manager.session, mongoOngoingEmailAddressValidationCollectionName)
_, err = mgoCollection.Upsert(bson.M{"emailaddress": info.EmailAddress}, info)
return
} | [
"func",
"(",
"manager",
"*",
"Manager",
")",
"SaveEmailAddressValidationInformation",
"(",
"info",
"*",
"EmailAddressValidationInformation",
")",
"(",
"err",
"error",
")",
"{",
"mgoCollection",
":=",
"db",
".",
"GetCollection",
"(",
"manager",
".",
"session",
",",... | //SaveEmailAddressValidationInformation stores a validated emailaddress | [
"SaveEmailAddressValidationInformation",
"stores",
"a",
"validated",
"emailaddress"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/validation/db.go#L128-L132 |
13,980 | itsyouonline/identityserver | db/validation/db.go | GetValidatedPhoneNumbersByUsernames | func (manager *Manager) GetValidatedPhoneNumbersByUsernames(usernames []string) (validatedPhonenumbers []ValidatedPhonenumber, err error) {
mgoCollection := db.GetCollection(manager.session, mongoValidatedPhonenumbers)
qry := bson.M{
"username": bson.M{
"$in": usernames,
},
}
err = mgoCollection.Find(qry).All(&validatedPhonenumbers)
return
} | go | func (manager *Manager) GetValidatedPhoneNumbersByUsernames(usernames []string) (validatedPhonenumbers []ValidatedPhonenumber, err error) {
mgoCollection := db.GetCollection(manager.session, mongoValidatedPhonenumbers)
qry := bson.M{
"username": bson.M{
"$in": usernames,
},
}
err = mgoCollection.Find(qry).All(&validatedPhonenumbers)
return
} | [
"func",
"(",
"manager",
"*",
"Manager",
")",
"GetValidatedPhoneNumbersByUsernames",
"(",
"usernames",
"[",
"]",
"string",
")",
"(",
"validatedPhonenumbers",
"[",
"]",
"ValidatedPhonenumber",
",",
"err",
"error",
")",
"{",
"mgoCollection",
":=",
"db",
".",
"GetCo... | // Returns all validated phone numbers for every username | [
"Returns",
"all",
"validated",
"phone",
"numbers",
"for",
"every",
"username"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/validation/db.go#L225-L234 |
13,981 | itsyouonline/identityserver | db/validation/db.go | GetValidatedEmailAddressesByUsernames | func (manager *Manager) GetValidatedEmailAddressesByUsernames(usernames []string) (validatedEmails []ValidatedEmailAddress, err error) {
mgoCollection := db.GetCollection(manager.session, mongoValidatedEmailAddresses)
qry := bson.M{
"username": bson.M{
"$in": usernames,
},
}
// Avoid returning multiple email addresses for the same user
err = mgoCollection.Find(qry).All(&validatedEmails)
return
} | go | func (manager *Manager) GetValidatedEmailAddressesByUsernames(usernames []string) (validatedEmails []ValidatedEmailAddress, err error) {
mgoCollection := db.GetCollection(manager.session, mongoValidatedEmailAddresses)
qry := bson.M{
"username": bson.M{
"$in": usernames,
},
}
// Avoid returning multiple email addresses for the same user
err = mgoCollection.Find(qry).All(&validatedEmails)
return
} | [
"func",
"(",
"manager",
"*",
"Manager",
")",
"GetValidatedEmailAddressesByUsernames",
"(",
"usernames",
"[",
"]",
"string",
")",
"(",
"validatedEmails",
"[",
"]",
"ValidatedEmailAddress",
",",
"err",
"error",
")",
"{",
"mgoCollection",
":=",
"db",
".",
"GetColle... | // Returns all validated email addresses for every username | [
"Returns",
"all",
"validated",
"email",
"addresses",
"for",
"every",
"username"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/validation/db.go#L244-L254 |
13,982 | itsyouonline/identityserver | identityservice/service.go | AddRoutes | func (service *Service) AddRoutes(router *mux.Router) {
// User API
user.UsersInterfaceRoutes(router, user.UsersAPI{SmsService: service.smsService, PhonenumberValidationService: service.phonenumberValidationService, EmailService: service.emailService, EmailAddressValidationService: service.emailaddresValidationService})
userdb.InitModels()
totp.InitModels()
see.InitModels()
iyoid.InitModels()
grants.InitModels()
// Company API
company.CompaniesInterfaceRoutes(router, company.CompaniesAPI{})
companydb.InitModels()
//contracts API
contract.ContractsInterfaceRoutes(router, contract.ContractsAPI{})
contractdb.InitModels()
// Organization API
organization.OrganizationsInterfaceRoutes(router, organization.OrganizationsAPI{
EmailAddressValidationService: service.emailaddresValidationService,
PhonenumberValidationService: service.phonenumberValidationService,
})
userorganization.UsersusernameorganizationsInterfaceRoutes(router, userorganization.UsersusernameorganizationsAPI{})
organizationdb.InitModels()
// Initialize Validation models
validationdb.InitModels()
// Initialize Password models
password.InitModels()
// Initialize registry models
registry.InitModels()
// Initialize keystore models
keystore.InitModels()
// Initialize registration models
registration.InitModels()
persistentlog.InitModels()
} | go | func (service *Service) AddRoutes(router *mux.Router) {
// User API
user.UsersInterfaceRoutes(router, user.UsersAPI{SmsService: service.smsService, PhonenumberValidationService: service.phonenumberValidationService, EmailService: service.emailService, EmailAddressValidationService: service.emailaddresValidationService})
userdb.InitModels()
totp.InitModels()
see.InitModels()
iyoid.InitModels()
grants.InitModels()
// Company API
company.CompaniesInterfaceRoutes(router, company.CompaniesAPI{})
companydb.InitModels()
//contracts API
contract.ContractsInterfaceRoutes(router, contract.ContractsAPI{})
contractdb.InitModels()
// Organization API
organization.OrganizationsInterfaceRoutes(router, organization.OrganizationsAPI{
EmailAddressValidationService: service.emailaddresValidationService,
PhonenumberValidationService: service.phonenumberValidationService,
})
userorganization.UsersusernameorganizationsInterfaceRoutes(router, userorganization.UsersusernameorganizationsAPI{})
organizationdb.InitModels()
// Initialize Validation models
validationdb.InitModels()
// Initialize Password models
password.InitModels()
// Initialize registry models
registry.InitModels()
// Initialize keystore models
keystore.InitModels()
// Initialize registration models
registration.InitModels()
persistentlog.InitModels()
} | [
"func",
"(",
"service",
"*",
"Service",
")",
"AddRoutes",
"(",
"router",
"*",
"mux",
".",
"Router",
")",
"{",
"// User API",
"user",
".",
"UsersInterfaceRoutes",
"(",
"router",
",",
"user",
".",
"UsersAPI",
"{",
"SmsService",
":",
"service",
".",
"smsServi... | //AddRoutes registers the http routes with the router. | [
"AddRoutes",
"registers",
"the",
"http",
"routes",
"with",
"the",
"router",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/service.go#L61-L102 |
13,983 | itsyouonline/identityserver | identityservice/service.go | GetCookieSecret | func GetCookieSecret() string {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
cookie, err := config.GetByKey("cookieSecret")
if err != nil {
log.Debug("No cookie secret found, generating a new one")
secret, err := generateCookieSecret(32)
if err != nil {
log.Panic("Cannot generate secret cookie")
}
cookie.Key = "cookieSecret"
cookie.Value = secret
err = config.Insert(cookie)
// Key was inserted by another instance in the meantime
if db.IsDup(err) {
cookie, err = config.GetByKey("cookieSecret")
if err != nil {
log.Panic("Cannot retreive cookie secret")
}
}
}
log.Debug("Cookie secret: ", cookie.Value)
return cookie.Value
} | go | func GetCookieSecret() string {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
cookie, err := config.GetByKey("cookieSecret")
if err != nil {
log.Debug("No cookie secret found, generating a new one")
secret, err := generateCookieSecret(32)
if err != nil {
log.Panic("Cannot generate secret cookie")
}
cookie.Key = "cookieSecret"
cookie.Value = secret
err = config.Insert(cookie)
// Key was inserted by another instance in the meantime
if db.IsDup(err) {
cookie, err = config.GetByKey("cookieSecret")
if err != nil {
log.Panic("Cannot retreive cookie secret")
}
}
}
log.Debug("Cookie secret: ", cookie.Value)
return cookie.Value
} | [
"func",
"GetCookieSecret",
"(",
")",
"string",
"{",
"session",
":=",
"db",
".",
"GetSession",
"(",
")",
"\n",
"defer",
"session",
".",
"Close",
"(",
")",
"\n\n",
"config",
":=",
"globalconfig",
".",
"NewManager",
"(",
")",
"\n",
"globalconfig",
".",
"Ini... | // GetCookieSecret gets the cookie secret from mongodb if it exists otherwise, generate a new one and save it | [
"GetCookieSecret",
"gets",
"the",
"cookie",
"secret",
"from",
"mongodb",
"if",
"it",
"exists",
"otherwise",
"generate",
"a",
"new",
"one",
"and",
"save",
"it"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/service.go#L123-L158 |
13,984 | itsyouonline/identityserver | identityservice/service.go | FilterAuthorizedScopes | func (service *Service) FilterAuthorizedScopes(r *http.Request, username string, grantedTo string, requestedscopes []string) (authorizedScopes []string, err error) {
authorization, err := userdb.NewManager(r).GetAuthorization(username, grantedTo)
if authorization == nil || err != nil {
return
}
authorizedScopes = authorization.FilterAuthorizedScopes(requestedscopes)
return
} | go | func (service *Service) FilterAuthorizedScopes(r *http.Request, username string, grantedTo string, requestedscopes []string) (authorizedScopes []string, err error) {
authorization, err := userdb.NewManager(r).GetAuthorization(username, grantedTo)
if authorization == nil || err != nil {
return
}
authorizedScopes = authorization.FilterAuthorizedScopes(requestedscopes)
return
} | [
"func",
"(",
"service",
"*",
"Service",
")",
"FilterAuthorizedScopes",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"username",
"string",
",",
"grantedTo",
"string",
",",
"requestedscopes",
"[",
"]",
"string",
")",
"(",
"authorizedScopes",
"[",
"]",
"string",... | //FilterAuthorizedScopes filters the requested scopes to the ones that are authorizated, if no authorization exists, authorizedScops is nil | [
"FilterAuthorizedScopes",
"filters",
"the",
"requested",
"scopes",
"to",
"the",
"ones",
"that",
"are",
"authorizated",
"if",
"no",
"authorization",
"exists",
"authorizedScops",
"is",
"nil"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/service.go#L161-L170 |
13,985 | itsyouonline/identityserver | identityservice/service.go | GetOauthSecret | func GetOauthSecret(service string) (string, error) {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
secretModel, err := config.GetByKey(service + "-secret")
if err != nil {
log.Errorf("No Oauth secret found for %s. Please insert it into the collection globalconfig with key %s-secret",
service, service)
}
return secretModel.Value, err
} | go | func GetOauthSecret(service string) (string, error) {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
secretModel, err := config.GetByKey(service + "-secret")
if err != nil {
log.Errorf("No Oauth secret found for %s. Please insert it into the collection globalconfig with key %s-secret",
service, service)
}
return secretModel.Value, err
} | [
"func",
"GetOauthSecret",
"(",
"service",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"session",
":=",
"db",
".",
"GetSession",
"(",
")",
"\n",
"defer",
"session",
".",
"Close",
"(",
")",
"\n\n",
"config",
":=",
"globalconfig",
".",
"NewManager... | // GetOauthSecret gets the oauth secret from mongodb for a specified service. If it doesn't exist, an error gets logged. | [
"GetOauthSecret",
"gets",
"the",
"oauth",
"secret",
"from",
"mongodb",
"for",
"a",
"specified",
"service",
".",
"If",
"it",
"doesn",
"t",
"exist",
"an",
"error",
"gets",
"logged",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/service.go#L229-L241 |
13,986 | itsyouonline/identityserver | identityservice/service.go | GetOauthClientID | func GetOauthClientID(service string) (string, error) {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
clientIDModel, err := config.GetByKey(service + "-clientid")
log.Warn(clientIDModel.Value)
if err != nil {
log.Errorf("No Oauth client id found for %s. Please insert it into the collection globalconfig with key %s-clientid",
service, service)
}
return clientIDModel.Value, err
} | go | func GetOauthClientID(service string) (string, error) {
session := db.GetSession()
defer session.Close()
config := globalconfig.NewManager()
globalconfig.InitModels()
clientIDModel, err := config.GetByKey(service + "-clientid")
log.Warn(clientIDModel.Value)
if err != nil {
log.Errorf("No Oauth client id found for %s. Please insert it into the collection globalconfig with key %s-clientid",
service, service)
}
return clientIDModel.Value, err
} | [
"func",
"GetOauthClientID",
"(",
"service",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"session",
":=",
"db",
".",
"GetSession",
"(",
")",
"\n",
"defer",
"session",
".",
"Close",
"(",
")",
"\n\n",
"config",
":=",
"globalconfig",
".",
"NewManag... | // GetOauthClientID gets the oauth secret from mongodb for a specified service. If it doesn't exist, an error gets logged. | [
"GetOauthClientID",
"gets",
"the",
"oauth",
"secret",
"from",
"mongodb",
"for",
"a",
"specified",
"service",
".",
"If",
"it",
"doesn",
"t",
"exist",
"an",
"error",
"gets",
"logged",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/identityservice/service.go#L244-L258 |
13,987 | itsyouonline/identityserver | db/keystore/db.go | Create | func (m *Manager) Create(key *KeyStoreKey) error {
err := m.getKeyStoreCollection().Insert(key)
if mgo.IsDup(err) {
return db.ErrDuplicate
}
return err
} | go | func (m *Manager) Create(key *KeyStoreKey) error {
err := m.getKeyStoreCollection().Insert(key)
if mgo.IsDup(err) {
return db.ErrDuplicate
}
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"Create",
"(",
"key",
"*",
"KeyStoreKey",
")",
"error",
"{",
"err",
":=",
"m",
".",
"getKeyStoreCollection",
"(",
")",
".",
"Insert",
"(",
"key",
")",
"\n",
"if",
"mgo",
".",
"IsDup",
"(",
"err",
")",
"{",
"... | // Create a new KeyStore key entry. | [
"Create",
"a",
"new",
"KeyStore",
"key",
"entry",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/keystore/db.go#L44-L50 |
13,988 | itsyouonline/identityserver | credentials/password/keyderivation/crypt/sha512crypt/sha512crypt.go | New | func New() crypt.Crypter {
return &crypter{
common.Salt{
MagicPrefix: []byte(MagicPrefix),
SaltLenMin: SaltLenMin,
SaltLenMax: SaltLenMax,
RoundsDefault: RoundsDefault,
RoundsMin: RoundsMin,
RoundsMax: RoundsMax,
},
}
} | go | func New() crypt.Crypter {
return &crypter{
common.Salt{
MagicPrefix: []byte(MagicPrefix),
SaltLenMin: SaltLenMin,
SaltLenMax: SaltLenMax,
RoundsDefault: RoundsDefault,
RoundsMin: RoundsMin,
RoundsMax: RoundsMax,
},
}
} | [
"func",
"New",
"(",
")",
"crypt",
".",
"Crypter",
"{",
"return",
"&",
"crypter",
"{",
"common",
".",
"Salt",
"{",
"MagicPrefix",
":",
"[",
"]",
"byte",
"(",
"MagicPrefix",
")",
",",
"SaltLenMin",
":",
"SaltLenMin",
",",
"SaltLenMax",
":",
"SaltLenMax",
... | // New returns a new Crypter computing the SHA512-crypt password hashing. | [
"New",
"returns",
"a",
"new",
"Crypter",
"computing",
"the",
"SHA512",
"-",
"crypt",
"password",
"hashing",
"."
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/credentials/password/keyderivation/crypt/sha512crypt/sha512crypt.go#L39-L50 |
13,989 | itsyouonline/identityserver | db/grants/db.go | GetGrantsForUser | func (m *Manager) GetGrantsForUser(username string, globalID string) (*SavedGrants, error) {
var sg SavedGrants
err := m.collection.Find(bson.M{"username": username, "globalid": globalID}).One(&sg)
return &sg, err
} | go | func (m *Manager) GetGrantsForUser(username string, globalID string) (*SavedGrants, error) {
var sg SavedGrants
err := m.collection.Find(bson.M{"username": username, "globalid": globalID}).One(&sg)
return &sg, err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetGrantsForUser",
"(",
"username",
"string",
",",
"globalID",
"string",
")",
"(",
"*",
"SavedGrants",
",",
"error",
")",
"{",
"var",
"sg",
"SavedGrants",
"\n\n",
"err",
":=",
"m",
".",
"collection",
".",
"Find",
... | // GetGrantsForUser gets all the saved grants for a user and globalID | [
"GetGrantsForUser",
"gets",
"all",
"the",
"saved",
"grants",
"for",
"a",
"user",
"and",
"globalID"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L64-L70 |
13,990 | itsyouonline/identityserver | db/grants/db.go | GetByGrant | func (m *Manager) GetByGrant(grant Grant, globalID string) ([]SavedGrants, error) {
var usersWithGrant []SavedGrants
if err := m.collection.Find(bson.M{"grants": grant, "globalid": globalID}).All(&usersWithGrant); err != nil {
return nil, err
}
return usersWithGrant, nil
} | go | func (m *Manager) GetByGrant(grant Grant, globalID string) ([]SavedGrants, error) {
var usersWithGrant []SavedGrants
if err := m.collection.Find(bson.M{"grants": grant, "globalid": globalID}).All(&usersWithGrant); err != nil {
return nil, err
}
return usersWithGrant, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetByGrant",
"(",
"grant",
"Grant",
",",
"globalID",
"string",
")",
"(",
"[",
"]",
"SavedGrants",
",",
"error",
")",
"{",
"var",
"usersWithGrant",
"[",
"]",
"SavedGrants",
"\n\n",
"if",
"err",
":=",
"m",
".",
"... | // GetByGrant returns all SavedGrants where the given grant is in the list of grants | [
"GetByGrant",
"returns",
"all",
"SavedGrants",
"where",
"the",
"given",
"grant",
"is",
"in",
"the",
"list",
"of",
"grants"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L73-L81 |
13,991 | itsyouonline/identityserver | db/grants/db.go | UpserGrant | func (m *Manager) UpserGrant(username, globalID string, grant Grant) error {
// Count the amount of grants we already have first
sg, err := m.GetGrantsForUser(username, globalID)
if err != nil && !db.IsNotFound(err) {
return err
}
if db.IsNotFound(err) {
sg = &SavedGrants{}
}
if len(sg.Grants) >= maxGrants {
return ErrGrantLimitReached
}
_, err = m.collection.Upsert(bson.M{"username": username, "globalid": globalID}, bson.M{"$addToSet": bson.M{"grants": grant}})
return err
} | go | func (m *Manager) UpserGrant(username, globalID string, grant Grant) error {
// Count the amount of grants we already have first
sg, err := m.GetGrantsForUser(username, globalID)
if err != nil && !db.IsNotFound(err) {
return err
}
if db.IsNotFound(err) {
sg = &SavedGrants{}
}
if len(sg.Grants) >= maxGrants {
return ErrGrantLimitReached
}
_, err = m.collection.Upsert(bson.M{"username": username, "globalid": globalID}, bson.M{"$addToSet": bson.M{"grants": grant}})
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"UpserGrant",
"(",
"username",
",",
"globalID",
"string",
",",
"grant",
"Grant",
")",
"error",
"{",
"// Count the amount of grants we already have first",
"sg",
",",
"err",
":=",
"m",
".",
"GetGrantsForUser",
"(",
"username... | // UpserGrant adds a new grent for a user by an organization | [
"UpserGrant",
"adds",
"a",
"new",
"grent",
"for",
"a",
"user",
"by",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L84-L99 |
13,992 | itsyouonline/identityserver | db/grants/db.go | UpdateGrant | func (m *Manager) UpdateGrant(username, globalID string, oldgrant, newgrant Grant) error {
// First remove the old grant
err := m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$pull": bson.M{"grants": oldgrant}})
if err != nil {
return err
}
// Now insert the new one
return m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$addToSet": bson.M{"grants": newgrant}})
} | go | func (m *Manager) UpdateGrant(username, globalID string, oldgrant, newgrant Grant) error {
// First remove the old grant
err := m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$pull": bson.M{"grants": oldgrant}})
if err != nil {
return err
}
// Now insert the new one
return m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$addToSet": bson.M{"grants": newgrant}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"UpdateGrant",
"(",
"username",
",",
"globalID",
"string",
",",
"oldgrant",
",",
"newgrant",
"Grant",
")",
"error",
"{",
"// First remove the old grant",
"err",
":=",
"m",
".",
"collection",
".",
"Update",
"(",
"bson",
... | // UpdateGrant updates an old grant to a new one | [
"UpdateGrant",
"updates",
"an",
"old",
"grant",
"to",
"a",
"new",
"one"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L102-L110 |
13,993 | itsyouonline/identityserver | db/grants/db.go | DeleteUserGrant | func (m *Manager) DeleteUserGrant(username, globalID string, grant Grant) error {
return m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$pull": bson.M{"grants": grant}})
} | go | func (m *Manager) DeleteUserGrant(username, globalID string, grant Grant) error {
return m.collection.Update(bson.M{"username": username, "globalid": globalID}, bson.M{"$pull": bson.M{"grants": grant}})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"DeleteUserGrant",
"(",
"username",
",",
"globalID",
"string",
",",
"grant",
"Grant",
")",
"error",
"{",
"return",
"m",
".",
"collection",
".",
"Update",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"username",
... | // DeleteUserGrant removes a single grant from a user for an organization | [
"DeleteUserGrant",
"removes",
"a",
"single",
"grant",
"from",
"a",
"user",
"for",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L113-L115 |
13,994 | itsyouonline/identityserver | db/grants/db.go | DeleteUserGrants | func (m *Manager) DeleteUserGrants(username, globalID string) error {
return m.collection.Remove(bson.M{"username": username, "globalid": globalID})
} | go | func (m *Manager) DeleteUserGrants(username, globalID string) error {
return m.collection.Remove(bson.M{"username": username, "globalid": globalID})
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"DeleteUserGrants",
"(",
"username",
",",
"globalID",
"string",
")",
"error",
"{",
"return",
"m",
".",
"collection",
".",
"Remove",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"username",
",",
"\"",
"\"",
":",
... | // DeleteUserGrants removes all grants given to a user by an organization | [
"DeleteUserGrants",
"removes",
"all",
"grants",
"given",
"to",
"a",
"user",
"by",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L118-L120 |
13,995 | itsyouonline/identityserver | db/grants/db.go | DeleteOrgGrants | func (m *Manager) DeleteOrgGrants(globalID string) error {
_, err := m.collection.RemoveAll(bson.M{"globalid": globalID})
return err
} | go | func (m *Manager) DeleteOrgGrants(globalID string) error {
_, err := m.collection.RemoveAll(bson.M{"globalid": globalID})
return err
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"DeleteOrgGrants",
"(",
"globalID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"m",
".",
"collection",
".",
"RemoveAll",
"(",
"bson",
".",
"M",
"{",
"\"",
"\"",
":",
"globalID",
"}",
")",
"\n",
"retur... | // DeleteOrgGrants remooves all grants given by an organization | [
"DeleteOrgGrants",
"remooves",
"all",
"grants",
"given",
"by",
"an",
"organization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/grants/db.go#L123-L126 |
13,996 | itsyouonline/identityserver | db/persistentlog/db.go | SaveLog | func (m *Manager) SaveLog(log *PersistentLog) error {
return m.collection.Insert(log)
} | go | func (m *Manager) SaveLog(log *PersistentLog) error {
return m.collection.Insert(log)
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"SaveLog",
"(",
"log",
"*",
"PersistentLog",
")",
"error",
"{",
"return",
"m",
".",
"collection",
".",
"Insert",
"(",
"log",
")",
"\n",
"}"
] | // SaveLog stores a new PersistentLog entry | [
"SaveLog",
"stores",
"a",
"new",
"PersistentLog",
"entry"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/db/persistentlog/db.go#L40-L42 |
13,997 | itsyouonline/identityserver | oauthservice/jwt.go | JWTHandler | func (service *Service) JWTHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
log.Debug("Error parsing form: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
requestedScopeParameter := r.FormValue("scope")
audiences := strings.TrimSpace(r.FormValue("aud"))
//First check if the user uses an existing jwt to authenticate and authorize itself
idToken, err := oauth2.GetValidJWT(r, &service.jwtSigningKey.PublicKey)
if err != nil {
log.Warning(err)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
var tokenString string
if idToken != nil {
tokenString, err = service.createNewJWTFromParent(r, idToken, requestedScopeParameter, audiences)
} else {
//If no jwt was supplied, check if an old school access_token was used
accessToken := r.Header.Get("Authorization")
//Get the actual token out of the header (accept 'token ABCD' as well as just 'ABCD' and ignore some possible whitespace)
accessToken = strings.TrimSpace(strings.TrimPrefix(accessToken, "token"))
if accessToken == "" {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
oauthMgr := NewManager(r)
var at *AccessToken
at, err = oauthMgr.GetAccessToken(accessToken)
if err != nil {
log.Error(err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
if at == nil || at.IsExpired() {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
validity := parseValidity(r)
tokenString, err = service.convertAccessTokenToJWT(r, at, requestedScopeParameter, audiences, validity)
}
if err == errUnauthorized {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
if err != nil {
log.Error(err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.Header().Set("Content-type", "application/jwt")
w.Write([]byte(tokenString))
} | go | func (service *Service) JWTHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
log.Debug("Error parsing form: ", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
requestedScopeParameter := r.FormValue("scope")
audiences := strings.TrimSpace(r.FormValue("aud"))
//First check if the user uses an existing jwt to authenticate and authorize itself
idToken, err := oauth2.GetValidJWT(r, &service.jwtSigningKey.PublicKey)
if err != nil {
log.Warning(err)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
var tokenString string
if idToken != nil {
tokenString, err = service.createNewJWTFromParent(r, idToken, requestedScopeParameter, audiences)
} else {
//If no jwt was supplied, check if an old school access_token was used
accessToken := r.Header.Get("Authorization")
//Get the actual token out of the header (accept 'token ABCD' as well as just 'ABCD' and ignore some possible whitespace)
accessToken = strings.TrimSpace(strings.TrimPrefix(accessToken, "token"))
if accessToken == "" {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
oauthMgr := NewManager(r)
var at *AccessToken
at, err = oauthMgr.GetAccessToken(accessToken)
if err != nil {
log.Error(err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
if at == nil || at.IsExpired() {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
validity := parseValidity(r)
tokenString, err = service.convertAccessTokenToJWT(r, at, requestedScopeParameter, audiences, validity)
}
if err == errUnauthorized {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
if err != nil {
log.Error(err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
w.Header().Set("Content-type", "application/jwt")
w.Write([]byte(tokenString))
} | [
"func",
"(",
"service",
"*",
"Service",
")",
"JWTHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"err",
":=",
"r",
".",
"ParseForm",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"D... | //JWTHandler returns a JWT with claims that are a subset of the scopes available to the authorizing token | [
"JWTHandler",
"returns",
"a",
"JWT",
"with",
"claims",
"that",
"are",
"a",
"subset",
"of",
"the",
"scopes",
"available",
"to",
"the",
"authorizing",
"token"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/jwt.go#L26-L87 |
13,998 | itsyouonline/identityserver | oauthservice/jwt.go | parseValidity | func parseValidity(r *http.Request) int64 {
validityString := r.FormValue("validity")
var validity int64
if validityString == "" {
validity = -1
} else {
var err error
validity, err = strconv.ParseInt(validityString, 10, 64)
if err != nil {
log.Debugf("Failed to parse validity argument (%v) as int64", validityString)
validity = -1
}
}
return validity
} | go | func parseValidity(r *http.Request) int64 {
validityString := r.FormValue("validity")
var validity int64
if validityString == "" {
validity = -1
} else {
var err error
validity, err = strconv.ParseInt(validityString, 10, 64)
if err != nil {
log.Debugf("Failed to parse validity argument (%v) as int64", validityString)
validity = -1
}
}
return validity
} | [
"func",
"parseValidity",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"int64",
"{",
"validityString",
":=",
"r",
".",
"FormValue",
"(",
"\"",
"\"",
")",
"\n",
"var",
"validity",
"int64",
"\n",
"if",
"validityString",
"==",
"\"",
"\"",
"{",
"validity",
"... | // parseValidity parses the validity parameter from the request | [
"parseValidity",
"parses",
"the",
"validity",
"parameter",
"from",
"the",
"request"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/jwt.go#L449-L463 |
13,999 | itsyouonline/identityserver | oauthservice/jwt.go | getRealLabel | func getRealLabel(requestedLabel string, t string, authorization *user.Authorization) string {
if authorization == nil {
return requestedLabel
}
switch t {
case "email":
for _, m := range authorization.EmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "phone":
for _, m := range authorization.Phonenumbers {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "validatedemail":
for _, m := range authorization.ValidatedEmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "validatedphone":
for _, m := range authorization.ValidatedEmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
}
return ""
} | go | func getRealLabel(requestedLabel string, t string, authorization *user.Authorization) string {
if authorization == nil {
return requestedLabel
}
switch t {
case "email":
for _, m := range authorization.EmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "phone":
for _, m := range authorization.Phonenumbers {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "validatedemail":
for _, m := range authorization.ValidatedEmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
case "validatedphone":
for _, m := range authorization.ValidatedEmailAddresses {
if requestedLabel == m.RequestedLabel {
return m.RealLabel
}
}
break
}
return ""
} | [
"func",
"getRealLabel",
"(",
"requestedLabel",
"string",
",",
"t",
"string",
",",
"authorization",
"*",
"user",
".",
"Authorization",
")",
"string",
"{",
"if",
"authorization",
"==",
"nil",
"{",
"return",
"requestedLabel",
"\n",
"}",
"\n",
"switch",
"t",
"{"... | // getRealLabel loads the real label from an authorization | [
"getRealLabel",
"loads",
"the",
"real",
"label",
"from",
"an",
"authorization"
] | 333d78810c675fe259e970c190f35a5dc5586569 | https://github.com/itsyouonline/identityserver/blob/333d78810c675fe259e970c190f35a5dc5586569/oauthservice/jwt.go#L588-L623 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.