예제 #1
0
func matchScopes(granted []string, requested []string, session *oauth2.Session, c fosite.Client) bool {
	scopes := &fosite.DefaultScopes{Scopes: granted}
	for _, r := range requested {
		if !scopes.Grant(r) {
			logrus.WithFields(logrus.Fields{
				"reason":           "scope mismatch",
				"granted_scopes":   granted,
				"requested_scopes": requested,
				"audience":         c.GetID(),
				"subject":          session.Subject,
			}).Infof("Authentication failed.")
			return false
		}
	}

	return true
}
예제 #2
0
func compare(t *testing.T, c fosite.Client, k string) {
	assert.Equal(t, c.GetID(), "1234", "%s", k)
	assert.NotEmpty(t, c.GetHashedSecret(), "%s", k)
	assert.Equal(t, c.GetRedirectURIs(), []string{"http://redirect"}, "%s", k)
}