diff --git a/README.md b/README.md index 6acd9ef..7693be0 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ [Farsi](./README.fa-IR.md) | English -## Codeigniter Shield OAuth + +## Codeigniter Shield OAuth + [![PHPCSFixer](https://github.com/datamweb/shield-oauth/actions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/phpcsfixer.yml) [![PHPStan](https://github.com/datamweb/shield-oauth/actions/workflows/phpstan.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/phpstan.yml) [![Rector](https://github.com/datamweb/shield-oauth/actions/workflows/rector.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/rector.yml) [![PHPCPD](https://github.com/datamweb/shield-oauth/actions/workflows/phpcpd.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/phpcpd.yml) -

Logo Shield OAuth

[![Latest Stable Version](https://poser.pugx.org/datamweb/shield-oauth/v?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Total Downloads](https://poser.pugx.org/datamweb/shield-oauth/downloads?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Latest Unstable Version](https://poser.pugx.org/datamweb/shield-oauth/v/unstable?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![License](https://poser.pugx.org/datamweb/shield-oauth/license?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![PHP Version Require](https://poser.pugx.org/datamweb/shield-oauth/require/php?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) - -`Shield OAuth` helps you to provide the possibility of login or registering users through the OAuth service. Currently, `Shield OAuth` supports `Google OAuth` and `GitHub OAuth` by default, but it allows you to implement it for any other service, including **Yahoo**, **Facebook**, **Twitter**, **LinkedIn**, **GitLab** and ... +`Shield OAuth` helps you to provide the possibility of login or registering users through the OAuth service. Currently, `Shield OAuth` supports `Google OAuth`, `GitHub and `Microsoft` OAuth` by default, but it allows you to implement it for any other service, including **Yahoo**, **Facebook**, **Twitter**, **LinkedIn**, **GitLab** and ... In `Shield OAuth`, it has been considered to be easy to use by developers and the possibility of expansion to connect to other services in the shortest possible time. @@ -25,12 +25,15 @@ In `Shield OAuth`, it has been considered to be easy to use by developers and th - [cURL Library](https://www.php.net/manual/en/book.curl.php) to be installed in your version of PHP ## Shield OAuth Documentation + In the documentation, I have explained how to **install**, **configure**, and how to **create custom class `NewOAuth`** connections to other services. Documentation for `Shield OAuth` can be found on the [docs](https://www.shield-oauth.codeigniter4.ir/). ## License + This project is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details. ## Acknowledgements + Every open-source project depends on it's contributors to be a success. The following users have contributed in one manner or another in making Codeigniter `Shield OAuth`: diff --git a/docs/get_keys.md b/docs/get_keys.md index 54a60ec..27b7fbb 100644 --- a/docs/get_keys.md +++ b/docs/get_keys.md @@ -1,19 +1,22 @@ # How To Get Keys - -Obviously, receiving Keys is not directly related to `Shield OAuth`, however, to improve the documentation and convenience of our users, Therefore, we have provided helpful links on how to get keys from the three most important Google, GitHub and Yahoo. For other services, you can find the relevant steps by searching. + +Obviously, receiving Keys is not directly related to `Shield OAuth`, however, to improve the documentation and convenience of our users, Therefore, we have provided helpful links on how to get keys from the three most important Google, GitHub, Microsoft and Yahoo. For other services, you can find the relevant steps by searching. - [How To Get Keys](#how-to-get-keys) - [Explanation About Callback](#explanation-about-callback) - [Get GitHub Keys](#get-github-keys) - [Get Google Keys](#get-google-keys) +- [Get Microsoft Keys](#get-microsoft-keys) - [Get Yahoo Keys](#get-yahoo-keys) - # Explanation About Callback + What is important in receiving the keys in each of the services is the **Callback (Redirect)** address. In this regard, you must register the address as below. + ``` https://yourBaseUrl.com/oauth/call-back ``` + `Shield OAuth` allows you to put another expression in the place of `call-back`, for this you need to make the necessary changes in the `app/Config/ShieldOAuthConfig.php` file. ```php @@ -27,10 +30,17 @@ https://yourBaseUrl.com/oauth/any-name-for-call-back ``` # Get GitHub Keys + The guide to get the `client_id` & `client_secret` keys on GitHub is [here](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app) in full. # Get Google Keys + The guide to get the `client_id` & `client_secret` keys on Google is [here](https://www.balbooa.com/gridbox-documentation/how-to-get-google-client-id-and-client-secret). +# Get Microsoft Keys + +The guide to get the `client_id` & `client_secret` keys on Microsoft is [here](https://docs.microfocus.com/doc/CS_MicrosoftOffice365_Content/1.2.3/GetClientInputs) or [here](https://learn.microsoft.com/en-us/answers/questions/834401/hi-i-want-my-client-id-and-client-secret-key). + # Get Yahoo Keys + The guide to get the `client_id` & `client_secret` keys on Yahoo is [here](https://developer.yahoo.com/apps/create/). diff --git a/docs/index.md b/docs/index.md index 9eeb1c4..4425221 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,5 @@ # Shield OAuth Documentation + [![PHPCSFixer](https://github.com/datamweb/shield-oauth/actions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/phpcsfixer.yml) [![PHPStan](https://github.com/datamweb/shield-oauth/actions/workflows/phpstan.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/phpstan.yml) [![Rector](https://github.com/datamweb/shield-oauth/actions/workflows/rector.yml/badge.svg)](https://github.com/datamweb/shield-oauth/actions/workflows/rector.yml) @@ -8,16 +9,15 @@ [![Latest Stable Version](https://poser.pugx.org/datamweb/shield-oauth/v?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Total Downloads](https://poser.pugx.org/datamweb/shield-oauth/downloads?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Latest Unstable Version](https://poser.pugx.org/datamweb/shield-oauth/v/unstable?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![License](https://poser.pugx.org/datamweb/shield-oauth/license?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![PHP Version Require](https://poser.pugx.org/datamweb/shield-oauth/require/php?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) - -`Shield OAuth` helps you to provide the possibility of login or registering users through the OAuth service. Currently, `Shield OAuth` supports `Google OAuth` and `GitHub OAuth` by default, but it allows you to implement it for any other service, including Yahoo, Facebook, Twitter, LinkedIn, GitLab and ..., this is very easy. Just create a class in route `app\Libraries\ShieldOAuth`! +`Shield OAuth` helps you to provide the possibility of login or registering users through the OAuth service. Currently, `Shield OAuth` supports `Google OAuth`, `GitHub OAuth` and `Microsoft OAuth` by default, but it allows you to implement it for any other service, including Yahoo, Facebook, Twitter, LinkedIn, GitLab and ..., this is very easy. Just create a class in route `app\Libraries\ShieldOAuth`! more info see [How to add other services](add_other_oauth.md). ## Links: -* [Installation Guide](install.md) -* [How To Get Keys](get_keys.md) -* [How to add other services](add_other_oauth.md) -* [Quick Start](quickstart.md) +- [Installation Guide](install.md) +- [How To Get Keys](get_keys.md) +- [How to add other services](add_other_oauth.md) +- [Quick Start](quickstart.md) ## Acknowledgements diff --git a/docs/install.md b/docs/install.md index 791d23a..0dc6b1c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -25,15 +25,17 @@ If you have it installed as a phar, or otherwise you will need to adjust the way ```console composer require datamweb/shield-oauth:dev-develop ``` + > **Note** -> You can manually install `Shield OAuth` by extracting the project file to path `app\ThirdParty\shield-oauth` and then adding -> ->```php +> You can manually install `Shield OAuth` by extracting the project file to path `app\ThirdParty\shield-oauth` and then adding +> +> ```php > public $psr4 = [ > // add this line > 'Datamweb\ShieldOAuth' => APPPATH . 'ThirdParty/shield-oauth/src', > ]; -> ``` +> ``` +> > to the `app/Config/Autoload.php` file, however we do not recommend this. Please use the Composer. ## Add Required Columns @@ -47,6 +49,7 @@ Data of Table "users": | id | username | status | ... | first_name | last_name | avatar | +----+----------+--------+-...-+------------+-----------+--------+ ``` + Therefore, you can add `first_name`, `last_name`, and `avatar` columns to table `users` by any method you want or run the migrations: ```console @@ -57,7 +60,7 @@ php spark migrate -n Datamweb\ShieldOAuth > By default, `Shield OAuth` uses columns named `first_name`, `last_name`, and `avatar`. > For any reason, if you want to consider another name for them columns, you can do it through the config file(`config/ShieldOAuthConfig.php`) and set the desired values in: -```php +```php public array $usersColumnsName = [ 'first_name' => 'first_name', 'last_name' => 'last_name', @@ -79,7 +82,7 @@ public $globals = [ ]; ``` -## Set keys +## Set keys Receive keys `client_id` and `client_secret` from each OAuth server. To connect to any of the servers, you need to receive`client_id` and `client_secret` from them and then set them in file **.env** Or `app/Config/ShieldOAuthConfig`. @@ -112,17 +115,26 @@ public array $oauthConfigs = [ 'client_secret' => 'fsdfsdfsgdgrdg', // ... ], + 'microsoft' => [ + 'client_id' => 'example-098a-43sd-9813-9747f3gg6f6h', + 'client_secret' => 'example-qw53-446r-tyy1-856ff9ue8fdf', + // ... + ], // and other services... ``` ## Adding all login button with OAuth in View + The last step is to, You can create your own buttons in views, what is important is that the addresses should be as follows: + ```html http://localhost:8080/oauth/google http://localhost:8080/oauth/github http://localhost:8080/oauth/yahoo +http://localhost:8080/oauth/microsoft