-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plans for Gitea support? #589
Comments
I did some try.
modify Gitea.php like: --- oauth/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php 2022-05-04 05:38:50.000000000 +0800
+++ oauth/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Gitea.php 2022-08-15 16:14:14.177387810 +0800
@@ -10,7 +10,7 @@
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\OAuth2\Token\StdOAuth2Token;
-class GitHub extends AbstractService
+class Gitea extends AbstractService
{
/**
* Defined scopes, see http://developer.github.com/v3/oauth/ for definitions.
@@ -124,6 +124,8 @@
*/
const SCOPE_PUBLIC_KEY_ADMIN = 'admin:public_key';
+ const GITEA_HOST_DEFAULT = 'http://x.x.x.x';
+
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -134,7 +136,7 @@
parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri('https://api.github.com/');
+ $this->baseApiUri = new Uri(static::GITEA_HOST_DEFAULT . '/api/v1/');
}
}
@@ -143,7 +145,7 @@
*/
public function getAuthorizationEndpoint()
{
- return new Uri('https://github.com/login/oauth/authorize');
+ return new Uri(static::GITEA_HOST_DEFAULT . '/login/oauth/authorize');
}
/**
@@ -151,7 +153,7 @@
*/
public function getAccessTokenEndpoint()
{
- return new Uri('https://github.com/login/oauth/access_token');
+ return new Uri(static::GITEA_HOST_DEFAULT . '/login/oauth/access_token');
}
/**
diff -r -u oauthgithub/action.php oauthgitea/action.php
--- oauthgithub/action.php 2021-12-15 14:51:44.000000000 +0800
+++ oauthgitea/action.php 2022-08-15 16:27:27.457387715 +0800
@@ -1,11 +1,11 @@
<?php
-use OAuth\OAuth2\Service\GitHub;
+use OAuth\OAuth2\Service\Gitea;
/**
* Service Implementation for oAuth Github authentication
*/
-class action_plugin_oauthgithub extends \dokuwiki\plugin\oauth\Adapter
+class action_plugin_oauthgitea extends \dokuwiki\plugin\oauth\Adapter
{
/** * @inheritDoc */
@@ -34,13 +34,13 @@
/** @inheritDoc */
public function getScopes()
{
- return [GitHub::SCOPE_USER_EMAIL];
+ return [Gitea::SCOPE_USER_EMAIL];
}
/** @inheritDoc */
public function getLabel()
{
- return 'GitHub';
+ return 'Gitea';
}
/** @inheritDoc */
diff -r -u oauthgithub/plugin.info.txt oauthgitea/plugin.info.txt
--- oauthgithub/plugin.info.txt 2021-12-15 14:51:44.000000000 +0800
+++ oauthgitea/plugin.info.txt 2022-08-15 14:29:23.693388561 +0800
@@ -1,1 +1,1 @@
-base oauthgithub
+base oauthgitea It works! But, I do not know the means of those const variables like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hope so.
The text was updated successfully, but these errors were encountered: