コード例 #1
0
ファイル: db.go プロジェクト: mohabusama/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:    []string{"authorizationcode"},
		Unique: true,
	} //Do not drop duplicates since it would hijack another authorizationrequest, better to error out

	db.EnsureIndex(requestsCollectionName, index)

	//TODO: unique username/clientid combination

	automaticExpiration := mgo.Index{
		Key:         []string{"CreatedAt"},
		ExpireAfter: time.Second * 10,
		Background:  true,
	}
	db.EnsureIndex(requestsCollectionName, automaticExpiration)

	index = mgo.Index{
		Key:    []string{"AccessToken"},
		Unique: true,
	} //Do not drop duplicates since it would hijack another authorizationrequest, better to error out

	db.EnsureIndex(tokensCollectionName, index)

	//TODO: unique username/clientid combination

	automaticExpiration = mgo.Index{
		Key:         []string{"CreatedAt"},
		ExpireAfter: AccessTokenExpiration,
		Background:  true,
	}
	db.EnsureIndex(tokensCollectionName, automaticExpiration)

}
コード例 #2
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	// TODO: Use model tags to ensure indices/constraints.
	index := mgo.Index{
		Key:    []string{"globalid"},
		Unique: true,
	}

	db.EnsureIndex(mongoCollectionName, index)

	// Index the logo collection
	index = mgo.Index{
		Key:    []string{"globalid"},
		Unique: true,
	}

	db.EnsureIndex(logoCollectionName, index)

	index = mgo.Index{
		Key:    []string{"globalid", "username"},
		Unique: true,
	}

	db.EnsureIndex(last2FACollectionName, index)

	// remove last2fa entries after 31 days
	automatic2FAExpiration := mgo.Index{
		Key:         []string{"last2fa"},
		ExpireAfter: time.Second * 3600 * 24 * 31,
		Background:  true,
	}
	db.EnsureIndex(last2FACollectionName, automatic2FAExpiration)
}
コード例 #3
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:      []string{"username"},
		Unique:   true,
		DropDups: true,
	}

	db.EnsureIndex(mongoUsersCollectionName, index)

	// Removes users without valid 2 factor authentication after 3 days
	automaticUserExpiration := mgo.Index{
		Key:         []string{"expire"},
		ExpireAfter: time.Second * 3600 * 24 * 3,
		Background:  true,
	}
	db.EnsureIndex(mongoUsersCollectionName, automaticUserExpiration)
}
コード例 #4
0
//initLoginModels initialize models in mongo
func (service *Service) initRegistrationModels() {
	index := mgo.Index{
		Key:      []string{"sessionkey"},
		Unique:   true,
		DropDups: false,
	}

	db.EnsureIndex(mongoRegistrationCollectionName, index)

	automaticExpiration := mgo.Index{
		Key:         []string{"createdat"},
		ExpireAfter: time.Second * 60 * 10, //10 minutes
		Background:  true,
	}
	db.EnsureIndex(mongoRegistrationCollectionName, automaticExpiration)

}
コード例 #5
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:    []string{"contractid"},
		Unique: true,
	}

	db.EnsureIndex(mongoCollectionName, index)
}
コード例 #6
0
ファイル: db.go プロジェクト: mohabusama/identityserver
//InitModels initializes models in DB, if required.
func InitModels() {
	index := mgo.Index{
		Key:      []string{"globalid"},
		Unique:   true,
		DropDups: true,
	}

	db.EnsureIndex(COLLECTION_COMPANIES, index)
}
コード例 #7
0
ファイル: db.go プロジェクト: yveskerwyn/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	// TODO: Use model tags to ensure indices/constraints.
	index := mgo.Index{
		Key:    []string{"globalid"},
		Unique: true,
	}

	db.EnsureIndex(mongoCollectionName, index)
}
コード例 #8
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
// InitModels initializes models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:      []string{"username"},
		Unique:   true,
		DropDups: true,
	}

	db.EnsureIndex(mongoCollectionName, index)
}
コード例 #9
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:      []string{"key"},
		Unique:   true,
		DropDups: false,
	}

	db.EnsureIndex(mongoOngoingPhonenumberValidationCollectionName, index)
	db.EnsureIndex(mongoOngoingEmailAddressValidationCollectionName, index)

	automaticExpiration := mgo.Index{
		Key:         []string{"createdat"},
		ExpireAfter: time.Second * 60 * 10,
		Background:  true,
	}
	db.EnsureIndex(mongoOngoingPhonenumberValidationCollectionName, automaticExpiration)

	automaticExpiration = mgo.Index{
		Key:         []string{"createdat"},
		ExpireAfter: time.Second * 3600 * 48,
		Background:  true,
	}
	db.EnsureIndex(mongoOngoingEmailAddressValidationCollectionName, automaticExpiration)

	index = mgo.Index{
		Key:      []string{"username", "phonenumber"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoValidatedPhonenumbers, index)

	index = mgo.Index{
		Key:      []string{"phonenumber"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoValidatedPhonenumbers, index)

	index = mgo.Index{
		Key:      []string{"username", "emailaddress"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoValidatedEmailAddresses, index)
	index = mgo.Index{
		Key:      []string{"emailaddress"},
		Unique:   true,
		DropDups: true,
	}
	db.EnsureIndex(mongoValidatedEmailAddresses, index)

}
コード例 #10
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initializes models in mongo, if required.
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)
}
コード例 #11
0
ファイル: db.go プロジェクト: itsyouonline/identityserver
//InitModels initialize models in mongo, if required.
func InitModels() {
	index := mgo.Index{
		Key:    []string{"username"},
		Unique: true,
	}

	db.EnsureIndex(mongoRegistryCollectionName, index)

	index = mgo.Index{
		Key:    []string{"globalid"},
		Unique: true,
	}

	db.EnsureIndex(mongoRegistryCollectionName, index)

	index = mgo.Index{
		Key:    []string{"entries.key"},
		Unique: true,
	}

	db.EnsureIndex(mongoRegistryCollectionName, index)

}