Giter Club home page Giter Club logo

moodle-local_oauth's Introduction

OAuth2 Server Plugin for Moodle

It provides an OAuth2 server so that a user can use its Moodle account to log in to your application. Oauth2 Library has been taken from https://github.com/bshaffer/oauth2-server-php

Requirements

  • Moodle 2.8 o higher installed

  • Admin account

Installation steps

  1. Clone this repository in a directory named "oauth". $ git clone https://github.com/projectestac/moodle-local_oauth.git oauth

  2. Compress it to a .zip file.

  3. Log in to Moodle as an administrator.

  4. Search a block named Administration and look for Site Administration > Plugins > Install Plugins.

  5. Choose the .zip file and hit the button Install Plugin from the ZIP file.

  6. Make sure the directory path_to_moodle/local/ has writing permissions for moodle. If the validation is ok, install it.

  7. Go to Site Administration > Server > OAuth provider settings

  8. Click Add new client

  9. Fill in the form. Your Client Identifier and Client Secret (which will be given later) will be used for you to authenticate. The Redirect URL must be the URL mapping to your client that will be used.

How to use

  1. From your application, redirect the user to this URL: http://moodledomain.com/local/oauth/login.php?client_id=EXAMPLE&response_type=code (remember to replace the URL domain with the domain of Moodle and replace EXAMPLE with the Client Identifier given in the form.)

  2. The user must log in to Moodle and authorize your application to use its basic info.

  3. If it went all ok, the plugin should redirect the user to something like: http://yourapplicationdomain.com/foo?code=55c057549f29c428066cbbd67ca6b17099cb1a9e (that's a GET request to the Redirect URL given with the code parameter)

  4. Using the code given, your application must send a POST request to http://moodledomain.com/local/oauth/token.php having the following parameters: {'code': '55c057549f29c428066cbbd67ca6b17099cb1a9e', 'client_id': 'EXAMPLE', 'client_secret': 'codeGivenAfterTheFormWasFilled', 'grant_type': 'authorization_code', 'scope': 'user_info'}.

  5. If the correct credentials were given, the response should a JSON be like this: {"access_token":"79d687a0ea4910c6662b2e38116528fdcd65f0d1","expires_in":3600,"token_type":"Bearer","scope":"user_info","refresh_token":"c1de730eef1b2072b48799000ec7cde4ea6d2af0"}

  6. Finally, send a POST request to http://moodledomain.com/local/oauth/user_info.php passing the access token as a parameter, like: {'access_token':'79d687a0ea4910c6662b2e38116528fdcd65f0d1'}.

  7. If the token given is valid, a JSON containing the user information is returned. Ex: {"id":"22","username":"foobar","idnumber":"","firstname":"Foo","lastname":"Bar","email":"[email protected]","lang":"en","phone1":"5551619192","auth":"manual","country":"foo","description":"bar"}

Note: If testing in Postman, you need to set encoding to x-www-form-urlencoded for POST requests.

This plugin has been tested on Moodle 2.8 and Moodle 3.0

Contributors

Apart from people in this repository, also have contributed:

moodle-local_oauth's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-local_oauth's Issues

What is the user_id field is for?

Hi,
Thanks for developing and publishing the plugin. It saved us a lot of time :-)

Quick question: I can't understand what the "user_id' field is being used for under the plugins' configuration page. I didn't find an explicit mention of such a field in the OAuth 2 spec.

Thanks,
Alexander

Add Repository License

Hello, I'm currently looking at implementations of Moodle Oauth plugins and yours seems to be a solid option.
I would like to use/fork it for one of the tasks in my organization, however there is no license available for the repository and per GitHub policies it is considered to be a proprietary code that disallows such usage.

You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work.

Would it be possible for one of the maintainers to clarify that it is indeed possible to use your project and if possible add license of choice to repository so that there is no misunderstandings regarding it.
Thank you!

OpenID Connect

Hi,

We are trying to integrate authentication to another system through Moodle and I came across your plugin.

The other system (xwiki) only supports the use of OpenID Connect, though an extension, not just a simple OAuth 2 workflow, so we've been unable to make them play nicely, as the xwiki site is requesting scopes that moodle/local_oauth doesn't support, e.g. openid profile email address phone

Are you aware of any way to make this plugin work with oidc?

Thanks.

Login to Moodle

Hello

Thanks for publishing the plugin, it looks good.

I have a question regarding the redirection, after successful login when user goto moodle page will user be logged in or he needs to login again?

Regards
Hussain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.