메인 콘텐츠로 건너뛰기

사용자 정의 OAuth

노트

Casdoor는 사용자 정의 제공자를 지원합니다. 그러나, 사용자 정의 제공자는 3-legged OAuth의 표준 프로세스를 따라야 하며, Token URLUserInfo URL의 반환 값은 Casdoor에서 지정한 형식을 준수해야 합니다.

Overview

Custom OAuth providers allow you to integrate any OAuth 2.0 compliant authentication service with Casdoor, even if it's not officially supported. This is useful when you want to integrate with:

  • Internal enterprise OAuth servers
  • Self-hosted authentication systems
  • Third-party services not yet officially supported by Casdoor

Multiple Custom Providers Support

Casdoor supports up to 10 different custom OAuth providers simultaneously. When creating custom providers, you can choose from the following types:

  • Custom - The first custom provider
  • Custom2 through Custom10 - Additional custom providers

This allows you to integrate multiple custom OAuth services without conflicts. Each custom provider maintains its own separate configuration and user data fields.

Creating a Custom Provider

To create a new custom provider, navigate to the provider page of Casdoor, and select one of the custom types ("Custom", "Custom2", "Custom3", etc.) in the Type field. 그런 다음 Client ID, Client Secret, Auth URL, Scope,Token URL, UserInfo URL, 그리고 Favicon을 입력해야 합니다.

image-20220418100744005

  • Auth URL은 사용자 정의 제공자의 OAuth 로그인 페이지 주소입니다.

    https://door.casdoor.com/login/oauth/authorizeAuth URL로 입력하면, 사용자가 이 사용자 정의 제공자로 로그인할 때 브라우저는 먼저 다음으로 리디렉션됩니다.

    https://door.casdoor.com/login/oauth/authorize?client_id={ClientID}&redirect_uri=https://{your-casdoor-hostname}/callback&state={State_generated_by_Casdoor}&response_type=code&scope={Scope} 

    인증이 완료된 후, 사용자 정의 제공자는 다음으로 리디렉션해야 합니다.

    https://{your-casdoor-hostname}/callback?code={code}

    이 단계 후에, Casdoor는 URL의 코드 매개변수를 인식합니다.

  • ScopeAuth URL에 접근할 때 전달되는 범위 매개변수이며, 사용자 정의 제공자의 요구 사항에 따라 채워야 합니다.

  • Token URL은 accessToken을 얻기 위한 API 엔드포인트입니다.

    이전 단계에서 코드를 얻으면, Casdoor는 이를 사용하여 accessToken을 얻어야 합니다.

    https://door.casdoor.com/api/login/oauth/access_tokenToken URL로 입력하면, Casdoor는 다음 명령을 사용하여 접근합니다.

    curl -X POST -u "{ClientID}:{ClientSecret}" --data-binary "code={code}&grant_type=authorization_code&redirect_uri=https://{your-casdoor-hostname}/callback" https://door.casdoor.com/api/login/oauth/access_token

    사용자 정의 제공자는 적어도 다음 정보를 반환해야 합니다.

    {
    "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ixxxxxxxxxxxxxx",
    "refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6xxxxxxxxxxxxxx",
    "token_type": "Bearer",
    "expires_in": 10080,
    "scope": "openid profile email"
    }
  • UserInfo URL은 accessToken을 통해 사용자 정보를 얻기 위한 API 엔드포인트입니다.

    https://door.casdoor.com/api/userinfoUserInfo URL로 입력하면, Casdoor는 다음 명령을 사용하여 접근합니다.

    curl -X GET -H "Authorization: Bearer {accessToken}" https://door.casdoor.com/api/userinfo

    사용자 정의 제공자는 적어도 다음 정보를 반환해야 합니다.

    {
    "name": "admin",
    "preferred_username": "Admin",
    "email": "admin@example.com",
    "picture": "https://casbin.org/img/casbin.svg"
    }
  • Favicon은 사용자 정의 제공자의 로고 URL입니다.

    이 로고는 다른 제3자 로그인 제공자와 함께 Casdoor의 로그인 페이지에 표시됩니다.