...

Source file src/github.com/ory/fosite/handler/oauth2/storage.go

Documentation: github.com/ory/fosite/handler/oauth2

     1  /*
     2   * Copyright © 2015-2018 Aeneas Rekkas <aeneas+oss@aeneas.io>
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   *
    16   * @author		Aeneas Rekkas <aeneas+oss@aeneas.io>
    17   * @copyright 	2015-2018 Aeneas Rekkas <aeneas+oss@aeneas.io>
    18   * @license 	Apache-2.0
    19   *
    20   */
    21  
    22  package oauth2
    23  
    24  import (
    25  	"context"
    26  
    27  	"github.com/ory/fosite"
    28  )
    29  
    30  type CoreStorage interface {
    31  	AuthorizeCodeStorage
    32  	AccessTokenStorage
    33  	RefreshTokenStorage
    34  }
    35  
    36  // AuthorizeCodeStorage handles storage requests related to authorization codes.
    37  type AuthorizeCodeStorage interface {
    38  	// GetAuthorizeCodeSession stores the authorization request for a given authorization code.
    39  	CreateAuthorizeCodeSession(ctx context.Context, code string, request fosite.Requester) (err error)
    40  
    41  	// GetAuthorizeCodeSession hydrates the session based on the given code and returns the authorization request.
    42  	// If the authorization code has been invalidated with `InvalidateAuthorizeCodeSession`, this
    43  	// method should return the ErrInvalidatedAuthorizeCode error.
    44  	//
    45  	// Make sure to also return the fosite.Requester value when returning the fosite.ErrInvalidatedAuthorizeCode error!
    46  	GetAuthorizeCodeSession(ctx context.Context, code string, session fosite.Session) (request fosite.Requester, err error)
    47  
    48  	// InvalidateAuthorizeCodeSession is called when an authorize code is being used. The state of the authorization
    49  	// code should be set to invalid and consecutive requests to GetAuthorizeCodeSession should return the
    50  	// ErrInvalidatedAuthorizeCode error.
    51  	InvalidateAuthorizeCodeSession(ctx context.Context, code string) (err error)
    52  }
    53  
    54  type AccessTokenStorage interface {
    55  	CreateAccessTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
    56  
    57  	GetAccessTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
    58  
    59  	DeleteAccessTokenSession(ctx context.Context, signature string) (err error)
    60  }
    61  
    62  type RefreshTokenStorage interface {
    63  	CreateRefreshTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
    64  
    65  	GetRefreshTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
    66  
    67  	DeleteRefreshTokenSession(ctx context.Context, signature string) (err error)
    68  }
    69  

View as plain text